fix: Ensure 'Content-Type' header is set for POST, PUT, and DELETE requests

This commit is contained in:
Mo Tarbin
2026-01-26 23:08:13 -05:00
parent ad45bafd62
commit 66b9e9b5c1

View File

@@ -100,7 +100,6 @@ class ApiClient {
getHeaders(customHeaders = {}) { getHeaders(customHeaders = {}) {
const headers = { const headers = {
'Content-Type': 'application/json',
...customHeaders, ...customHeaders,
} }
@@ -231,6 +230,10 @@ class ApiClient {
} }
async post(endpoint, data, options = {}) { async post(endpoint, data, options = {}) {
options.headers = options.headers || {}
if (!options.headers['Content-Type']) {
options.headers['Content-Type'] = 'application/json'
}
return this.request(endpoint, { return this.request(endpoint, {
...options, ...options,
method: 'POST', method: 'POST',
@@ -239,6 +242,10 @@ class ApiClient {
} }
async put(endpoint, data, options = {}) { async put(endpoint, data, options = {}) {
options.headers = options.headers || {}
if (!options.headers['Content-Type']) {
options.headers['Content-Type'] = 'application/json'
}
return this.request(endpoint, { return this.request(endpoint, {
...options, ...options,
method: 'PUT', method: 'PUT',
@@ -247,6 +254,10 @@ class ApiClient {
} }
async delete(endpoint, options = {}) { async delete(endpoint, options = {}) {
options.headers = options.headers || {}
if (!options.headers['Content-Type']) {
options.headers['Content-Type'] = 'application/json'
}
return this.request(endpoint, { ...options, method: 'DELETE' }) return this.request(endpoint, { ...options, method: 'DELETE' })
} }