diff --git a/lib/client/listActions.ts b/lib/client/listActions.ts index 01288ae..463da11 100644 --- a/lib/client/listActions.ts +++ b/lib/client/listActions.ts @@ -4,14 +4,14 @@ import { useRoute, useRouter } from "#app"; const base = `/user/me`; -export const favourites = (values: (any & { _id: number })[], id: number, remove: boolean, type: "story" | "author") => { +export const favourites = async (values: (any & { _id: number })[], id: number, remove: boolean, type: "story" | "author") => { values?.splice( values!.findIndex((a) => a._id == id), 1, ); const key = type === "story" ? "stories" : "authors"; const todo = [id]; - useApiFetch(`${base}/favs`, { + await useApiFetch(`${base}/favs`, { method: "put", body: { [key]: { @@ -22,7 +22,7 @@ export const favourites = (values: (any & { _id: number })[], id: number, remove }); }; -export const subscriptions = ( +export const subscriptions = async ( values: ((any & { _id: number }) | number)[], id: number, action: "hide" | "subscribe" | "unsubscribe", @@ -36,7 +36,7 @@ export const subscriptions = ( values!.findIndex((a) => a._id == id || a == id), 1, ); - useApiFetch(`${base}/${action}`, { + await useApiFetch(`${base}/${action}`, { body: { push: { [type]: [id], @@ -46,7 +46,7 @@ export const subscriptions = ( method: "put", }); } else if (action == "subscribe") { - useApiFetch(`${base}/subscriptions`, { + await useApiFetch(`${base}/subscriptions`, { body: { push: { [type]: [id], @@ -56,7 +56,7 @@ export const subscriptions = ( method: "put", }); } else if (action == "unsubscribe") { - useApiFetch(`${base}/subscriptions`, { + await useApiFetch(`${base}/subscriptions`, { body: { pull: { [type]: [id],