mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Updated /api/batch to return cache
This commit is contained in:
parent
805bc57bbb
commit
c86ea1a74f
1 changed files with 6 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ export async function POST(request: Request) {
|
||||||
const errors = [];
|
const errors = [];
|
||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
let cache = null;
|
||||||
for (const data of body) {
|
for (const data of body) {
|
||||||
// Recreate a fresh Request since `new Request(request)` will have the following error:
|
// Recreate a fresh Request since `new Request(request)` will have the following error:
|
||||||
// > Cannot read private member #state from an object whose class did not declare it
|
// > Cannot read private member #state from an object whose class did not declare it
|
||||||
|
|
@ -33,9 +34,12 @@ export async function POST(request: Request) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await send.POST(newRequest);
|
const response = await send.POST(newRequest);
|
||||||
|
const responseJson = await response.json();
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
errors.push({ index, response: await response.json() });
|
errors.push({ index, response: responseJson });
|
||||||
|
} else {
|
||||||
|
cache ??= responseJson.cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
@ -46,6 +50,7 @@ export async function POST(request: Request) {
|
||||||
processed: body.length - errors.length,
|
processed: body.length - errors.length,
|
||||||
errors: errors.length,
|
errors: errors.length,
|
||||||
details: errors,
|
details: errors,
|
||||||
|
cache,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return serverError(e);
|
return serverError(e);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue