Skip to content

Commit addb26d

Browse files
committed
fixed fetchJSON overriding headers with only content-type
1 parent 35e3a04 commit addb26d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

app/assets/javascripts/qpixel_api.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,17 @@ window.QPixel = {
334334
},
335335

336336
fetchJSON: async (uri, data, options = {}) => {
337+
const { headers = {}, ...restOptions } = options
338+
337339
/** @type {RequestInit} */
338340
const requestInit = {
339341
method: 'POST',
340342
body: options.method === 'GET' ? void 0 : JSON.stringify(data),
341-
headers: { 'Content-Type': 'application/json' },
342-
...options,
343+
headers: {
344+
'Content-Type': 'application/json',
345+
...headers,
346+
},
347+
...restOptions,
343348
};
344349

345350
return QPixel.fetch(uri, requestInit);

0 commit comments

Comments
 (0)