Initial commit: NestJS NextJS pnpm monorepo
This commit is contained in:
commit
610dcf202b
175 files changed
+25172
No files matched your search
@@ -0,0 +1,49 @@
|
||||
'use server'
|
||||
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { Category, CategoryCreate } from "@/apps/frontend/types/catalog";
|
||||
|
||||
export async function categoryCreate(data: CategoryCreate) {
|
||||
console.log(data);
|
||||
const result = await fetch('http://192.168.50.205/api/categories', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
console.log(result);
|
||||
|
||||
revalidatePath('/test')
|
||||
}
|
||||
|
||||
export async function categoryUpdate( id: string, data: Partial<CategoryCreate>) {
|
||||
console.log(data,id);
|
||||
const result = await fetch(`http://192.168.50.205/api/categories/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
console.log(result);
|
||||
revalidatePath('/test')
|
||||
}
|
||||
|
||||
export async function categoryFindAll():Promise<Category[]> {
|
||||
|
||||
const result = await fetch(`http://192.168.50.205/api/categories`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function categoryFindById(id:string):Promise<Category> {
|
||||
|
||||
const result = await fetch(`http://192.168.50.205/api/categories/${id}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in new issue
Block a user