full update
This commit is contained in:
23
src/api/fetchProject.ts
Normal file
23
src/api/fetchProject.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getApiBaseUrl } from "@/components/main/BaseUrl";
|
||||
import { Project } from "@/types/types";
|
||||
|
||||
export async function fetchProject(
|
||||
id: string,
|
||||
token = ""
|
||||
): Promise<Project | null> {
|
||||
try {
|
||||
const response = await fetch(`${getApiBaseUrl()}/projects/get/web/${id}`, {
|
||||
cache: "no-store",
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : "",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) return null;
|
||||
|
||||
const data = await response.json();
|
||||
return data?.project ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user