fix ( middleware )
deskripsi: - fix access api melalui middleware di: home, profile dan portofolio
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
export const apiGetUserProfile = async (path?: string) => {
|
||||
const response = await fetch(`/api/new/user${(path) ? path : ''}`)
|
||||
return await response.json().catch(() => null)
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if(!token) return null
|
||||
|
||||
const response = await fetch(`/api/new/user${(path) ? path : ''}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
|
||||
// console.log(await response.json())
|
||||
|
||||
if (!response.ok) return null
|
||||
const data: Record<string, any> = await response.json()
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user