Allow silencing API request errors.

The {silent: true} option in the new `opts` argument to the
`api` action does the trick.
This commit is contained in:
D. Berge
2025-07-25 13:30:26 +02:00
parent acb59035e4
commit 8cbacb9aa7

View File

@@ -1,5 +1,5 @@
async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb]) {
async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb, opts = {}]) {
try {
commit("queueRequest");
if (init && init.hasOwnProperty("body")) {
@@ -49,7 +49,9 @@ async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb
message = body.message;
}
}
await dispatch('showSnack', [message, "warning"]);
if (!opts?.silent) {
await dispatch('showSnack', [message, "warning"]);
}
}
} catch (err) {
if (err && err.name == "AbortError") return;