Release 202505311149

This commit is contained in:
pluja
2025-05-31 11:49:38 +00:00
parent 9a68112e24
commit 3afa824c18
3 changed files with 33 additions and 15 deletions

View File

@@ -13,15 +13,38 @@ export async function makeAdminApiCallInfo<T extends Misc.JSON.Object>({
}) {
const fullPath = new URL(`/api/v1${path}`, baseUrl).href
const fetchProsmise = fetch(fullPath, {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(input),
}).then((res) => {
try {
return res.json() as Promise<Misc.JSON.Value>
} catch (errJson: unknown) {
console.error(errJson)
try {
return res.text()
} catch (errText: unknown) {
console.error(errText)
return ''
}
}
})
let output: Misc.JSON.Value = ''
try {
output = await fetchProsmise
} catch (err: unknown) {
console.error(err)
output = err instanceof Error ? err.message : String(err)
}
return {
method,
path,
fullPath,
input,
output: await fetch(fullPath, {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(input),
}).then((res) => res.json() as Promise<Misc.JSON.Value>),
output,
}
}