mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:07:08 +00:00
Add flag to api action to fetch non-JSON data.
If {text:true} or another truthy value is passed as the
`text` option, the api action will use Response.text()
instead of Response.json().
This commit is contained in:
@@ -22,7 +22,7 @@ async function api ({state, commit, dispatch}, [resource, init = {}, cb]) {
|
||||
await dispatch('setCredentials');
|
||||
|
||||
try {
|
||||
return await res.json();
|
||||
return init.text ? (await res.text()) : (await res.json());
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
if (Number(res.headers.get("Content-Length")) === 0) {
|
||||
|
||||
Reference in New Issue
Block a user