Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Insert id property into return data
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 589d07f commit 680d916
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions functions/api/mod-queue/list.ts
Expand Up @@ -47,7 +47,6 @@ export async function onRequestGet(context: RequestContext) {
const prefix = types[entryType];
const table = tables[entryType];
const items = [];
console.log(!showClosed)
const { results }: { results?: { created_at: number; id: string }[] } =
/*
This is normally VERY BAD and can lead to injection attacks
Expand All @@ -62,9 +61,11 @@ export async function onRequestGet(context: RequestContext) {

if (results)
for (const { id } of results) {
items.push(
await context.env.DATA.get(`${prefix}_${id}`, { type: "json" })
);
const item = await context.env.DATA.get(`${prefix}_${id}`, {
type: "json",
});

if (item) items.push({ ...item, id });
}

return new Response(JSON.stringify(items.filter((v) => v !== null)), {
Expand Down

0 comments on commit 680d916

Please sign in to comment.