api project
This commit is contained in:
+17
-24
@@ -5,36 +5,29 @@ import api from '@/lib/axios';
|
||||
import { IResponse } from '@/models/response';
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
export async function getProjectCategories() {
|
||||
export async function getProjects() {
|
||||
const cookiesStore = await cookies();
|
||||
return api
|
||||
.get('/project_categories', {
|
||||
.get('/projects', {
|
||||
headers: {
|
||||
Cookie: cookiesStore.toString(),
|
||||
},
|
||||
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return Promise.resolve(data.data);
|
||||
})
|
||||
.then(({ data }) => Promise.resolve(data.data))
|
||||
.catch((error) => Promise.reject(error));
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function getProjects(
|
||||
categoryId: string,
|
||||
page = 1,
|
||||
): Promise<IResponse<IProjectCardProps[]>> {
|
||||
const cookiesStore = await cookies();
|
||||
return api
|
||||
.get(`/project_categories/${categoryId}/projects`, {
|
||||
headers: {
|
||||
Cookie: cookiesStore.toString(),
|
||||
},
|
||||
params: { page },
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return Promise.resolve(data);
|
||||
})
|
||||
.catch((error) => Promise.reject(error));
|
||||
}
|
||||
// export async function getProjectById(
|
||||
// projectId: string,
|
||||
// ): Promise<IProjectCardProps> {
|
||||
// const cookiesStore = await cookies();
|
||||
// return api
|
||||
// .get(`/projects/${projectId}`, {
|
||||
// headers: {
|
||||
// Cookie: cookiesStore.toString(),
|
||||
// },
|
||||
// })
|
||||
// .then(({ data }) => Promise.resolve(data.data))
|
||||
// .catch((error) => Promise.reject(error));
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user