소스 검색

Post data after followup section

Tatiana Inama 6 년 전
부모
커밋
88dfc761cc
1개의 변경된 파일16개의 추가작업 그리고 1개의 파일을 삭제
  1. 16 1
      src/App.tsx

+ 16 - 1
src/App.tsx

@@ -81,6 +81,20 @@ const App = () => {
     setCurrentPage(currentPage + 1);
     window.scrollTo(0, 0);
   }
+  const uploadData = () => {
+    const data = {
+      personalInformation: answers.personalInformation,
+      canvas: answers.canvas.map(data => ({
+        form: data.form,
+        path: data.path.exportJSON()
+      })),
+      email: answers.email
+    };
+    const postRequest = new XMLHttpRequest();
+    postRequest.open('POST', '/backend', true);
+    postRequest.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
+    postRequest.send(JSON.stringify(data));
+  }
   const sections = [
     Introduction({
       changePage: changePage
@@ -113,7 +127,8 @@ const App = () => {
           ...answers,
           email,
         });
-        changePage()
+        uploadData();
+        changePage();
       }
     }),
     FinishSection({})