Add clearvisits API endpoint and implement DELETE method***

***Handle error when no id is found in DELETE method***
***Update deleteData function in log page to use clearvisits API endpoint
This commit is contained in:
Sean Morley
2024-04-10 17:54:19 +00:00
parent bc0e1b4db2
commit 3dcad53004
3 changed files with 53 additions and 3 deletions

View File

@@ -52,6 +52,15 @@ export async function DELETE(event: RequestEvent): Promise<Response> {
// get id from the body
const { id } = await event.request.json();
if (!id) {
return new Response(JSON.stringify({ error: "No id found" }), {
status: 400,
headers: {
"Content-Type": "application/json",
},
});
}
let res = await db
.delete(userVisitedAdventures)
.where(