Browse Source

conditionally adds content-type json header if json is sent with request

master
Keviin Åberg Kultalahti 6 years ago
parent
commit
b7006e097c
  1. 3
      packages/client/src/api/api.js

3
packages/client/src/api/api.js

@ -20,9 +20,10 @@ const makeApiCall = async ({ method, url, body, json = true }) => {
const requestBody = json ? JSON.stringify(body) : body const requestBody = json ? JSON.stringify(body) : body
let headers = { let headers = {
Accept: "application/json", Accept: "application/json",
"Content-Type": "application/json", ...(json && { "Content-Type": "application/json" }),
"x-budibase-app-id": window["##BUDIBASE_APP_ID##"], "x-budibase-app-id": window["##BUDIBASE_APP_ID##"],
} }
if (!window["##BUDIBASE_IN_BUILDER##"]) { if (!window["##BUDIBASE_IN_BUILDER##"]) {
headers["x-budibase-type"] = "client" headers["x-budibase-type"] = "client"
} }

Loading…
Cancel
Save