👽 added async to api calls
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
14c24ae97e
commit
f417e575ea
8 changed files with 17 additions and 11 deletions
|
@ -19,7 +19,9 @@ interface QAData {
|
|||
questions: QuestionAnswerPair[];
|
||||
}
|
||||
|
||||
export const getUserQuestions = (respondentID: number): Promise<QAData> => {
|
||||
export const getUserQuestions = async (
|
||||
respondentID: number
|
||||
): Promise<QAData> => {
|
||||
let url = `http://localhost:8080/userquestions?respondentID=${respondentID}`;
|
||||
|
||||
const response = fetch(url, {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const postBugData = (bugText: string) => {
|
||||
export const postBugData = async (bugText: string) => {
|
||||
let url = "http://localhost:8080/submitbug";
|
||||
|
||||
const response = fetch(url, {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const postEvaluationData = (evaluationText: string) => {
|
||||
export const postEvaluationData = async (evaluationText: string) => {
|
||||
let url = "http://localhost:8080/submiteval";
|
||||
|
||||
const response = fetch(url, {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
export const postFormData = (respondentID: number, allFormAnswers: string) => {
|
||||
export const postFormData = async (
|
||||
respondentID: number,
|
||||
allFormAnswers: string
|
||||
) => {
|
||||
let url = "http://localhost:8080/submitanswers";
|
||||
|
||||
const response = fetch(url, {
|
||||
|
|
|
@ -2,7 +2,7 @@ interface postUserformDataReponse {
|
|||
respondentID: number;
|
||||
}
|
||||
|
||||
export const postUserformData = (
|
||||
export const postUserformData = async (
|
||||
age: string,
|
||||
education: string,
|
||||
healthcare_personnel: string,
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
goto(`${questionNum - 1}`)
|
||||
}
|
||||
|
||||
const handleFormSubmit = () => {
|
||||
const handleFormSubmit = async () => {
|
||||
let allFormAnswers:string | null = localStorage.getItem("allFormAnswers")
|
||||
let respondentID:string | null = localStorage.getItem("RespondentId")
|
||||
|
||||
if (allFormAnswers && respondentID) {
|
||||
postFormData(Number(respondentID), allFormAnswers)
|
||||
await postFormData(Number(respondentID), allFormAnswers)
|
||||
goto("/evaluation")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
let evaluationText:string = ""
|
||||
|
||||
const handleEvaluationSubmit = () => {
|
||||
const handleEvaluationSubmit = async () => {
|
||||
if (evaluationText) {
|
||||
postEvaluationData(evaluationText)
|
||||
await postEvaluationData(evaluationText)
|
||||
goto("/")
|
||||
} else {
|
||||
console.log("error");
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
let bugText:string = ""
|
||||
|
||||
const handleBugSubmit = () => {
|
||||
const handleBugSubmit = async () => {
|
||||
if (bugText) {
|
||||
postBugData(bugText)
|
||||
await postBugData(bugText)
|
||||
goto("javascript:history.back()")
|
||||
} else {
|
||||
console.log("error");
|
||||
|
|
Reference in a new issue