diff --git a/lib/www/client/source/src/store/modules/api/actions.js b/lib/www/client/source/src/store/modules/api/actions.js index 3722737..eee00f8 100644 --- a/lib/www/client/source/src/store/modules/api/actions.js +++ b/lib/www/client/source/src/store/modules/api/actions.js @@ -2,6 +2,17 @@ async function api ({state, commit, dispatch}, [resource, init = {}]) { try { // this.loading = true; + if (init && init.hasOwnProperty("body")) { + if (!init.headers) { + // As a convenience, we implicitly add the default content type + init.headers = { + "Content-Type": "application/json" + } + } + if (typeof init.body != "string") { + init.body = JSON.stringify(init.body); + } + } const res = await fetch(`${state.apiUrl}${resource}`, init); if (res.ok) { try {