mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:27:09 +00:00
Show API error messages if available
This commit is contained in:
@@ -35,7 +35,14 @@ async function api ({state, commit, dispatch}, [resource, init = {}, cb]) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await dispatch('showSnack', [res.statusText, "warning"]);
|
let message = res.statusText;
|
||||||
|
if (res.headers.get("Content-Type").match(/^application\/json/i)) {
|
||||||
|
const body = await res.json();
|
||||||
|
if (body.message) {
|
||||||
|
message = body.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await dispatch('showSnack', [message, "warning"]);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err && err.name == "AbortError") return;
|
if (err && err.name == "AbortError") return;
|
||||||
|
|||||||
Reference in New Issue
Block a user