浏览代码

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);
     setCurrentPage(currentPage + 1);
     window.scrollTo(0, 0);
     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 = [
   const sections = [
     Introduction({
     Introduction({
       changePage: changePage
       changePage: changePage
@@ -113,7 +127,8 @@ const App = () => {
           ...answers,
           ...answers,
           email,
           email,
         });
         });
-        changePage()
+        uploadData();
+        changePage();
       }
       }
     }),
     }),
     FinishSection({})
     FinishSection({})