fix ( authorization api )

deskripsi:
- memberi authorizetion ke api/new/*
This commit is contained in:
2025-01-08 17:41:04 +08:00
parent ebc9dcef04
commit 8c0af94ff8
5 changed files with 149 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
export const apiGetPortofolioByProfile = async (path?: string) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return null;
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/new/portofolio${path ? path : ""}`, {
headers: {
@@ -18,7 +18,7 @@ export const apiGetPortofolioByProfile = async (path?: string) => {
export const apiGetOnePortofolioById = async (path: string, cat: string) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return null;
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/new/portofolio/${path}?cat=${cat}`, {
headers: {
@@ -36,7 +36,7 @@ export const apiGetOnePortofolioById = async (path: string, cat: string) => {
export const apiDeletePortofolio = async (path: string) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return null;
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/new/portofolio/${path}`, {
method: "DELETE",
@@ -46,6 +46,5 @@ export const apiDeletePortofolio = async (path: string) => {
},
});
return await response.json().catch(() => null);
};