diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index cbb61396..b1252bbe 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -150,16 +150,22 @@ export default { return Promise.resolve(response); } }, - json(response) { + extractBody(response) { if (response.status == 204) { //no content, nothing to process return response; } let contentType = response.headers.get("content-type"); + if (!contentType) { + return response; + } // console.log("gzapi::JSON method, content type is:", contentType); - if (contentType && contentType.includes("json")) { + if (contentType.includes("json")) { return response.json(); } + if (contentType.includes("text/plain")) { + return response.text(); + } return response; }, apiErrorToHumanString(apiError) { @@ -348,7 +354,7 @@ export default { return new Promise(function getDataFromServer(resolve, reject) { fetch(that.APIUrl(route), that.fetchGetOptions()) .then(that.status) - .then(that.json) + .then(that.extractBody) // eslint-disable-next-line .then((response) => { resolve(response); @@ -380,7 +386,7 @@ export default { } fetch(that.APIUrl(route), fetchOptions) .then(that.status) - .then(that.json) + .then(that.extractBody) // eslint-disable-next-line .then((response) => { //Note: response.error indicates there is an error, however this is not an unusual condition @@ -401,7 +407,7 @@ export default { return new Promise(function removeDataFromServer(resolve, reject) { fetch(that.APIUrl(route), that.fetchRemoveOptions()) .then(that.status) - //.then(that.json) + //.then(that.extractBody) // eslint-disable-next-line .then((response) => { resolve(response); @@ -420,7 +426,7 @@ export default { return new Promise(function duplicateRecordOnServer(resolve, reject) { fetch(that.APIUrl(route), that.fetchPostOptions(null)) .then(that.status) - .then(that.json) + .then(that.extractBody) // eslint-disable-next-line .then((response) => { //Note: response.error indicates there is an error, however this is not an unusual condition @@ -465,7 +471,7 @@ export default { fetch(that.APIUrl("attachment"), fetchOptions) .then(that.status) - .then(that.json) + .then(that.extractBody) // eslint-disable-next-line .then((response) => { resolve(response); diff --git a/ayanova/src/views/ops-log.vue b/ayanova/src/views/ops-log.vue index fc6cbc49..fb6e7fd3 100644 --- a/ayanova/src/views/ops-log.vue +++ b/ayanova/src/views/ops-log.vue @@ -37,7 +37,7 @@ export default { .then(() => { vm.formState.ready = true; window.$gz.eventBus.$on("menu-click", clickHandler); - // vm.getDataFromApi(); + vm.formState.loading = false; }) .catch(err => { @@ -47,7 +47,7 @@ export default { }, data() { return { - log: [], + log: null, selectedLog: null, selectLists: { serverLogs: [] @@ -106,10 +106,10 @@ export default { vm.formState.serverError = res.error; window.$gz.form.setErrorBoxErrors(vm); } else { - if (res.data) { - vm.log = res.data; + if (res) { + vm.log = res; } else { - vm.log = null; + vm.log = vm.$ay.t("NoData"); } window.$gz.form.setFormState({