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 prefix = types[entryType];
|
||||||
const table = tables[entryType];
|
const table = tables[entryType];
|
||||||
const items = [];
|
const items = [];
|
||||||
console.log(!showClosed)
|
|
||||||
const { results }: { results?: { created_at: number; id: string }[] } =
|
const { results }: { results?: { created_at: number; id: string }[] } =
|
||||||
/*
|
/*
|
||||||
This is normally VERY BAD and can lead to injection attacks
|
This is normally VERY BAD and can lead to injection attacks
|
||||||
@ -62,9 +61,11 @@ export async function onRequestGet(context: RequestContext) {
|
|||||||
|
|
||||||
if (results)
|
if (results)
|
||||||
for (const { id } of results) {
|
for (const { id } of results) {
|
||||||
items.push(
|
const item = await context.env.DATA.get(`${prefix}_${id}`, {
|
||||||
await context.env.DATA.get(`${prefix}_${id}`, { type: "json" })
|
type: "json",
|
||||||
);
|
});
|
||||||
|
|
||||||
|
if (item) items.push({ ...item, id });
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(JSON.stringify(items.filter((v) => v !== null)), {
|
return new Response(JSON.stringify(items.filter((v) => v !== null)), {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user