Skip to content

Commit ffb783f

Browse files
committed
TEMP hardcode initial earthsearch provider
1 parent 645a75e commit ffb783f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

demo/app/src/hooks/useGetRequest.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { useEffect, useState } from "react";
2+
import useLocalStorage from "./useLocalStorage";
23

34
const useGetRequest = () => {
45
const [data, setData] = useState(null);
56
const [isLoading, setIsLoading] = useState(true);
67
const [error, setError] = useState("");
8+
const { userToken } = useLocalStorage();
79

810
useEffect(() => {
9-
fetch('/api/products')
11+
fetch('/api/products', {headers: new Headers({
12+
'Backend': 'earthsearch',
13+
'Authorization': `Bearer ${userToken}`
14+
})})
1015
.then((res) => res.json())
1116
.then((data) => {
1217
setData(data['products'])

demo/app/src/hooks/usePostRequest.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { useEffect, useState } from "react";
2+
import useLocalStorage from "./useLocalStorage";
23

34
const usePostRequest = (postParams) => {
45
const {params, provider} = !!postParams && postParams;
56
const [data, setData] = useState(null);
67
const [isLoading, setIsLoading] = useState(false);
78
const [error, setError] = useState("");
9+
const { userToken } = useLocalStorage();
810

911
useEffect(() => {
1012
if (params) {
@@ -14,7 +16,8 @@ const usePostRequest = (postParams) => {
1416
method: "POST",
1517
headers: {
1618
"Content-type": "application/json",
17-
"Backend": provider
19+
"Backend": provider,
20+
'Authorization': `Bearer ${userToken}`
1821
},
1922
body: JSON.stringify(params)
2023
})

0 commit comments

Comments
 (0)