-
Notifications
You must be signed in to change notification settings - Fork 2
basic app setup and api calls implemented #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tyler-Davenport
wants to merge
1
commit into
Repped-School:main
Choose a base branch
from
Tyler-Davenport:setup-and-promises
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { clientCredentials } from '../utils/client'; | ||
|
|
||
| const endpoint = clientCredentials.databaseURL; | ||
|
|
||
| const getQuestions = () => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/questions`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getQuestion = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/questions/${id}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const createQuestion = (questionData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/questions`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(questionData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const updateQuestion = (id, questionData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/questions/${id}`, { | ||
| method: 'PUT', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(questionData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const deleteQuestion = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/questions/${id}`, { | ||
| method: 'DELETE', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| export { getQuestions, getQuestion, createQuestion, updateQuestion, deleteQuestion }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { clientCredentials } from '../utils/client'; | ||
|
|
||
| const endpoint = clientCredentials.databaseURL; | ||
|
|
||
| const getResponses = () => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/responses`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getResponsesByQuestion = (questionId) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/responses?questionId=${questionId}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getResponse = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/responses/${id}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const createResponse = (responseData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/responses`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(responseData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const updateResponse = (id, responseData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/responses/${id}`, { | ||
| method: 'PUT', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(responseData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const deleteResponse = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/responses/${id}`, { | ||
| method: 'DELETE', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
|
Tyler-Davenport marked this conversation as resolved.
|
||
| .catch(reject); | ||
| }); | ||
|
|
||
| export { getResponses, getResponsesByQuestion, getResponse, createResponse, updateResponse, deleteResponse }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { clientCredentials } from '../utils/client'; | ||
|
|
||
| const endpoint = clientCredentials.databaseURL; | ||
|
|
||
| const getTrials = () => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trials`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getTrialsByCreator = (firebaseKey) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trials?creator=${firebaseKey}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getTrial = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trials/${id}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const createTrial = (trialData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trials`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(trialData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const updateTrial = (id, trialData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trials/${id}`, { | ||
| method: 'PUT', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(trialData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const deleteTrial = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trials/${id}`, { | ||
| method: 'DELETE', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
|
Tyler-Davenport marked this conversation as resolved.
|
||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| export { getTrials, getTrialsByCreator, getTrial, createTrial, updateTrial, deleteTrial }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { clientCredentials } from '../utils/client'; | ||
|
|
||
| const endpoint = clientCredentials.databaseURL; | ||
|
|
||
| const getTrialQuestionsByUser = (firebaseKey) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trial-questions?userId=${firebaseKey}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getTrialQuestion = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trial-questions/${id}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const createTrialQuestion = (trialQuestionData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trial-questions`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(trialQuestionData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const updateTrialQuestion = (id, trialQuestionData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trial-questions/${id}`, { | ||
| method: 'PUT', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(trialQuestionData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const deleteTrialQuestion = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/trial-questions/${id}`, { | ||
| method: 'DELETE', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
|
Tyler-Davenport marked this conversation as resolved.
|
||
| .catch(reject); | ||
| }); | ||
|
|
||
| export { getTrialQuestionsByUser, getTrialQuestion, createTrialQuestion, updateTrialQuestion, deleteTrialQuestion }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { clientCredentials } from '../utils/client'; | ||
|
|
||
| const endpoint = clientCredentials.databaseURL; | ||
|
|
||
| const getUsers = () => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/users`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const getUser = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/users/${id}`, { | ||
| method: 'GET', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const createUser = (userData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/users`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(userData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const updateUser = (id, userData) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/users/${id}`, { | ||
| method: 'PUT', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(userData), | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
| .catch(reject); | ||
| }); | ||
|
|
||
| const deleteUser = (id) => | ||
| new Promise((resolve, reject) => { | ||
| fetch(`${endpoint}/users/${id}`, { | ||
| method: 'DELETE', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }) | ||
| .then((res) => res.json()) | ||
| .then(resolve) | ||
|
Tyler-Davenport marked this conversation as resolved.
|
||
| .catch(reject); | ||
| }); | ||
|
Tyler-Davenport marked this conversation as resolved.
|
||
|
|
||
| export { getUsers, getUser, createUser, updateUser, deleteUser }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.