diff --git a/src/Components/Private/Edit/EditSystem.js b/src/Components/Private/Edit/EditSystem.js index b50429b0..13c2a81e 100644 --- a/src/Components/Private/Edit/EditSystem.js +++ b/src/Components/Private/Edit/EditSystem.js @@ -34,10 +34,7 @@ const EditSystem = ({ body: JSON.stringify(data), headers: { "Content-Type": "application/json", - Authorization: JSON.stringify(localStorage.getItem("token")).slice( - 1, - -1 - ), + Authorization: localStorage.getItem("token"), }, }) .then((res) => res.json()) diff --git a/src/Components/Private/Edit/EditSystemPrivacy.js b/src/Components/Private/Edit/EditSystemPrivacy.js index 3c2718fc..b7a32e70 100644 --- a/src/Components/Private/Edit/EditSystemPrivacy.js +++ b/src/Components/Private/Edit/EditSystemPrivacy.js @@ -21,10 +21,7 @@ const EditSystemPrivacy = ({ body: JSON.stringify(data), headers: { "Content-Type": "application/json", - Authorization: JSON.stringify(localStorage.getItem("token")).slice( - 1, - -1 - ), + Authorization: localStorage.getItem("token"), }, }) .then((res) => res.json()) diff --git a/src/Components/Private/MemberCard.js b/src/Components/Private/MemberCard.js index e44762e2..a8ed77f3 100644 --- a/src/Components/Private/MemberCard.js +++ b/src/Components/Private/MemberCard.js @@ -125,7 +125,7 @@ export default function MemberCard(props) { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setMember(prevState => {return {...prevState, ...data}}); @@ -146,7 +146,7 @@ export default function MemberCard(props) { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setMember(prevState => {return {...prevState, ...data}}); @@ -166,7 +166,7 @@ export default function MemberCard(props) { fetch(`${API_URL}m/${member.id}`,{ method: 'DELETE', headers: { - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (() => { setErrorAlert(false); setMemberDeleted(true); @@ -197,7 +197,7 @@ export default function MemberCard(props) { body: JSON.stringify(newdata), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setMember(prevState => {return {...prevState, ...data}}); diff --git a/src/Components/Private/MemberPage.js b/src/Components/Private/MemberPage.js index c991e490..b636b267 100644 --- a/src/Components/Private/MemberPage.js +++ b/src/Components/Private/MemberPage.js @@ -126,7 +126,7 @@ export default function MemberPage(props) { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setMember(prevState => {return {...prevState, ...data}}); @@ -147,7 +147,7 @@ export default function MemberPage(props) { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setMember(prevState => {return {...prevState, ...data}}); @@ -167,7 +167,7 @@ export default function MemberPage(props) { fetch(`${API_URL}m/${member.id}`,{ method: 'DELETE', headers: { - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (() => { setErrorAlert(false); setMemberDeleted(true); @@ -198,7 +198,7 @@ export default function MemberPage(props) { body: JSON.stringify(newdata), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setMember(prevState => {return {...prevState, ...data}}); diff --git a/src/Components/Private/Memberlist.js b/src/Components/Private/Memberlist.js index 83a26696..a630c015 100644 --- a/src/Components/Private/Memberlist.js +++ b/src/Components/Private/Memberlist.js @@ -53,7 +53,7 @@ export default function Memberlist() { fetch(`${API_URL}s/${userId}/members`,{ method: 'GET', headers: { - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then ( res => res.json() ).then (data => { setMembers(data) @@ -169,7 +169,7 @@ export default function Memberlist() { body: JSON.stringify(newdata), headers: { 'Content-Type': 'application/json', - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then (res => res.json() ).then (data => { setErrorAlert(false); diff --git a/src/Pages/Home.js b/src/Pages/Home.js index fd328e47..828e66cc 100644 --- a/src/Pages/Home.js +++ b/src/Pages/Home.js @@ -28,10 +28,7 @@ const { register, handleSubmit } = useForm(); fetch(`${API_URL}s/`, { method: "GET", headers: { - Authorization: JSON.stringify(localStorage.getItem("token")).slice( - 1, - -1 - ), + Authorization: localStorage.getItem("token"), }, }) // put all the system data in localstorage @@ -72,7 +69,7 @@ const { register, handleSubmit } = useForm(); fetch(`${API_URL}s/`,{ method: 'GET', headers: { - 'Authorization': JSON.stringify(localStorage.getItem("token")).slice(1, -1) + 'Authorization': localStorage.getItem("token") }}).then ( res => res.json() ).then (data => { localStorage.setItem('user', JSON.stringify(data));