diff --git a/src/pages/QuestionPage/index.js b/src/pages/QuestionPage/index.js index a9e179c..724a3e7 100644 --- a/src/pages/QuestionPage/index.js +++ b/src/pages/QuestionPage/index.js @@ -5,13 +5,24 @@ import Selector from "../../components/Selector"; import Question from "../../components/Question"; function QuestionPage() { + const url = process.env.REACT_APP_BACKEND_URL || "http://localhost:3333"; const [allQuestions, setAllQuestions] = useState([]); const [currentQuestion, setQuestion] = useState(0); const [answersDict, setAnswers] = useState({}); const [status, setStatus] = useState("CARREGANDO..."); + function sendAnswers() { + const headers = new Headers(); + headers.append("Content-Type", "application/json"); + + fetch(url + "/questions/answers", { + method: "POST", + body: JSON.stringify(answersDict), + headers, + }); + } + useEffect(() => { - const url = process.env.REACT_APP_BACKEND_URL || "http://localhost:3333"; fetch(url + "/questions") .then(async (resp) => { setAllQuestions((await resp.json()).allQuestions); @@ -25,15 +36,14 @@ function QuestionPage() { if (allQuestions.length === 0) return
{status}
; const questionObj = allQuestions[currentQuestion]; - const questionNumber = questionObj.number; return (