Insert id property into return data
This commit is contained in:
parent
589d07f1ac
commit
680d916894
@ -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
|
||||
@ -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)), {
|
||||
|
Loading…
x
Reference in New Issue
Block a user