Skip to content
Snippets Groups Projects
Verified Commit 9bbfc33b authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix(restapi): send correct header for requests

parent eceb2e60
No related branches found
No related tags found
No related merge requests found
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
* SPDX-License-Identifier: AGPL-3.0 * SPDX-License-Identifier: AGPL-3.0
*/ */
import { diff } from "../../../data/diff.mjs";
import { addAttributeToken } from "../../../dom/attributes.mjs"; import { addAttributeToken } from "../../../dom/attributes.mjs";
import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs"; import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs";
import { isArray } from "../../../types/is.mjs";
import { Datasource, dataSourceSymbol } from "../datasource.mjs"; import { Datasource, dataSourceSymbol } from "../datasource.mjs";
import { DatasourceStyleSheet } from "../stylesheet/datasource.mjs"; import { DatasourceStyleSheet } from "../stylesheet/datasource.mjs";
import { instanceSymbol } from "../../../constants.mjs"; import { instanceSymbol } from "../../../constants.mjs";
......
...@@ -94,6 +94,7 @@ class RestAPI extends Server { ...@@ -94,6 +94,7 @@ class RestAPI extends Server {
write: { write: {
init: { init: {
method: "POST", method: "POST",
headers: null,
}, },
responseCallback: null, responseCallback: null,
acceptedStatus: [200, 201], acceptedStatus: [200, 201],
...@@ -117,6 +118,7 @@ class RestAPI extends Server { ...@@ -117,6 +118,7 @@ class RestAPI extends Server {
read: { read: {
init: { init: {
method: "GET", method: "GET",
headers: null,
}, },
path: null, path: null,
responseCallback: null, responseCallback: null,
...@@ -140,6 +142,11 @@ class RestAPI extends Server { ...@@ -140,6 +142,11 @@ class RestAPI extends Server {
let init = this.getOption("read.init"); let init = this.getOption("read.init");
if (!isObject(init)) init = {}; if (!isObject(init)) init = {};
if (!init["method"]) init["method"] = "GET"; if (!init["method"]) init["method"] = "GET";
if (typeof init["headers"] !== "object") {
init["headers"] = {
"Accept": "application/json",
};
}
let callback = this.getOption("read.responseCallback"); let callback = this.getOption("read.responseCallback");
if (!callback) { if (!callback) {
...@@ -161,6 +168,7 @@ class RestAPI extends Server { ...@@ -161,6 +168,7 @@ class RestAPI extends Server {
if (typeof init["headers"] !== "object") { if (typeof init["headers"] !== "object") {
init["headers"] = { init["headers"] = {
"Content-Type": "application/json", "Content-Type": "application/json",
"Accept": "application/json",
}; };
} }
if (!init["method"]) init["method"] = "POST"; if (!init["method"]) init["method"] = "POST";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment