fix: (regression 0.29.0) wrong error message if an operation on Admin is unauthorized
Massimo Melina committed
Feb 10, 2023 at 14:22 UTC
e917705ead9e66a6612afe1b132ed65d961de72c
1 file changed
+4
-2
admin/src/api.ts
+4
-2
@@ -46,10 +46,12 @@ export function apiCall(cmd: string, params?: Dict, { timeout=undefined }={}) {
46
console.debug('API', cmd, params, '>>', json)
47
return json
48
})
49
- const msg = await res.text() || 'Failed API ' + cmd
49
+ let msg = await res.text() || 'Failed API ' + cmd
50
console.warn(msg + (params ? ' ' + JSON.stringify(params) : ''))
51
- if (res.status === 401)
51
+ if (res.status === 401) {
52
state.loginRequired = try_(() => JSON.parse(msg)?.any) !== false || 403
53
+ msg = "Unauthorized"
54
+ }
55
throw new ApiError(res.status, msg)
56
}, err => {
57
if (err?.message?.includes('fetch'))