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 @@
* SPDX-License-Identifier: AGPL-3.0
*/
import { diff } from "../../../data/diff.mjs";
import { addAttributeToken } from "../../../dom/attributes.mjs";
import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs";
import { isArray } from "../../../types/is.mjs";
import { Datasource, dataSourceSymbol } from "../datasource.mjs";
import { DatasourceStyleSheet } from "../stylesheet/datasource.mjs";
import { instanceSymbol } from "../../../constants.mjs";
......
......@@ -94,6 +94,7 @@ class RestAPI extends Server {
write: {
init: {
method: "POST",
headers: null,
},
responseCallback: null,
acceptedStatus: [200, 201],
......@@ -117,6 +118,7 @@ class RestAPI extends Server {
read: {
init: {
method: "GET",
headers: null,
},
path: null,
responseCallback: null,
......@@ -140,6 +142,11 @@ class RestAPI extends Server {
let init = this.getOption("read.init");
if (!isObject(init)) init = {};
if (!init["method"]) init["method"] = "GET";
if (typeof init["headers"] !== "object") {
init["headers"] = {
"Accept": "application/json",
};
}
let callback = this.getOption("read.responseCallback");
if (!callback) {
......@@ -161,6 +168,7 @@ class RestAPI extends Server {
if (typeof init["headers"] !== "object") {
init["headers"] = {
"Content-Type": "application/json",
"Accept": "application/json",
};
}
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