From 64780a009d83bf98b4610df683990af819cd429e Mon Sep 17 00:00:00 2001
From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it>
Date: Mon, 5 Apr 2021 10:14:48 +0200
Subject: [PATCH] Suppress errors

---
 src/App.tsx                                | 1 +
 src/components/AuthUser/AuthUser.tsx       | 9 +++++----
 src/components/LandingPage/LandingPage.tsx | 2 +-
 src/components/LandingPage/TeamPage.tsx    | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/App.tsx b/src/App.tsx
index eff1906..458470b 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -10,6 +10,7 @@ export const App: FC = () => (
       <Switch>
         <Route path="/auth" component={AuthUser} />
         <Route exact path="/" component={LandingPage} />
+        <Route exact path="/home" component={HomePage} />
       </Switch>
     </div>
   </Router>
diff --git a/src/components/AuthUser/AuthUser.tsx b/src/components/AuthUser/AuthUser.tsx
index 52b4a2b..5162104 100644
--- a/src/components/AuthUser/AuthUser.tsx
+++ b/src/components/AuthUser/AuthUser.tsx
@@ -7,10 +7,11 @@ export const AuthUser: FC = () => {
   useEffect(() => {
     axios
       .get('api/web/csrf')
-      .then((response) =>
-        sessionStorage.setItem('CSRF_TOKEN', response.data.token),
-      )
-      .catch((error) => console.log(error));
+      .then((response) => {
+        // Check this https://stackoverflow.com/questions/39254562/csrf-with-django-reactredux-using-axios
+        axios.defaults.headers.common['X-CSRFTOKEN'] = response.data.token;
+      })
+      .catch((error) => error);
   }, []);
   return (
     <Container maxWidth="sm">
diff --git a/src/components/LandingPage/LandingPage.tsx b/src/components/LandingPage/LandingPage.tsx
index 51f4226..5567be0 100644
--- a/src/components/LandingPage/LandingPage.tsx
+++ b/src/components/LandingPage/LandingPage.tsx
@@ -1,4 +1,4 @@
-import React, { FC, useEffect } from 'react';
+import React, { FC } from 'react';
 
 export const LandingPage: FC = () => (
   <>
diff --git a/src/components/LandingPage/TeamPage.tsx b/src/components/LandingPage/TeamPage.tsx
index 58d850b..b0a945e 100644
--- a/src/components/LandingPage/TeamPage.tsx
+++ b/src/components/LandingPage/TeamPage.tsx
@@ -1,4 +1,4 @@
-import React, { FC, useEffect } from 'react';
+import React, { FC } from 'react';
 
 export const TeamPage: FC = () => (
   <>
-- 
GitLab