Support async API callbacks in Vuex action

This commit is contained in:
D. Berge
2023-09-09 16:59:43 +02:00
parent a25676122c
commit e624dcdde0

View File

@@ -16,7 +16,7 @@ async function api ({state, commit, dispatch}, [resource, init = {}, cb]) {
const url = /^https?:\/\//i.test(resource) ? resource : (state.apiUrl + resource);
const res = await fetch(url, init);
if (typeof cb === 'function') {
cb(null, res);
await cb(null, res);
}
if (res.ok) {