fix ( middleware )
deskripsi: - fix access api melalui middleware di: home, profile dan portofolio
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
export const apiGetAllMap = async (path?: string) => {
|
||||
const response = await fetch(`/api/new/map${(path) ? path : ''}`)
|
||||
return await response.json().catch(() => null)
|
||||
}
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/new/map${path ? path : ""}`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
export const apiGetOneMapById = async (path: string) => {
|
||||
const response = await fetch(`/api/new/map/${path}`);
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/new/map/${path}`);
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ export function UiMap_MapBoxViewNew({ mapboxToken, }: { mapboxToken: string }) {
|
||||
try {
|
||||
setLoading(true)
|
||||
const response = await apiGetAllMap()
|
||||
if (response.success) {
|
||||
if (response) {
|
||||
setData(response.data)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user