mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
20 lines
722 B
TypeScript
20 lines
722 B
TypeScript
import { getAPIUrl } from "./config";
|
|
import { RequestBody } from "./utils/requests";
|
|
|
|
/*
|
|
This file includes only POST, PUT, DELETE requests
|
|
GET requests are called from the frontend using SWR (https://swr.vercel.app/)
|
|
*/
|
|
|
|
export async function deleteCollection(collection_id: any) {
|
|
return fetch(`${getAPIUrl()}collections/${collection_id}`, RequestBody("DELETE", null))
|
|
.then((result) => result.json())
|
|
.catch((error) => console.log("error", error));
|
|
}
|
|
|
|
// Create a new collection
|
|
export async function createCollection(collection: any) {
|
|
return fetch(`${getAPIUrl()}collections/`, RequestBody("POST", collection))
|
|
.then((result) => result.json())
|
|
.catch((error) => console.log("error", error));
|
|
}
|