API Investasi By Id & Fetch API Investasi By Id
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
export {
|
||||
apiGetAdminInvestasiCountDashboard,
|
||||
apiGetAdminInvestasiByStatus,
|
||||
apiGetAdminInvestasiById,
|
||||
|
||||
}
|
||||
const apiGetAdminInvestasiCountDashboard = async ({ name }:
|
||||
{ name: "Publish" | "Review" | "Reject" }) => {
|
||||
@@ -37,6 +39,7 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(`/api/admin/investasi/${status}${isPage}${isSearch}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
@@ -45,5 +48,24 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
},
|
||||
})
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
const apiGetAdminInvestasiById = async ({id} : {id: string}) => {
|
||||
const { token } = await fetch ("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
|
||||
const response = await fetch(`/api/admin/investasi/detail/${id}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
|
||||
console.log("Ini data Response", await response.json())
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
Reference in New Issue
Block a user