refactored api routes
This commit is contained in:
@@ -22,14 +22,14 @@ type CollectionStore = {
|
||||
const useCollectionStore = create<CollectionStore>()((set) => ({
|
||||
collections: [],
|
||||
setCollections: async () => {
|
||||
const response = await fetch("/api/routes/collections");
|
||||
const response = await fetch("/api/collections");
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) set({ collections: data.response });
|
||||
},
|
||||
addCollection: async (body) => {
|
||||
const response = await fetch("/api/routes/collections", {
|
||||
const response = await fetch("/api/collections", {
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -47,7 +47,7 @@ const useCollectionStore = create<CollectionStore>()((set) => ({
|
||||
return { ok: response.ok, data: data.response };
|
||||
},
|
||||
updateCollection: async (collection) => {
|
||||
const response = await fetch("/api/routes/collections", {
|
||||
const response = await fetch("/api/collections", {
|
||||
body: JSON.stringify(collection),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -67,7 +67,7 @@ const useCollectionStore = create<CollectionStore>()((set) => ({
|
||||
return { ok: response.ok, data: data.response };
|
||||
},
|
||||
removeCollection: async (id) => {
|
||||
const response = await fetch("/api/routes/collections", {
|
||||
const response = await fetch("/api/collections", {
|
||||
body: JSON.stringify({ id }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
Reference in New Issue
Block a user