Skip to content

Commit cbc539c

Browse files
authored
Merge pull request #15 from exaroton/content-type
Fix setting content type header in Request.getBody()
2 parents 5b9e692 + 6c2d09f commit cbc539c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Client.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,18 @@ export default class Client {
113113
/** @type {RequestInit} */
114114
const options = {
115115
method: request.method,
116-
headers: Object.assign({
117-
"authorization": "Bearer " + this.#apiToken,
118-
"user-agent": this.#userAgent
119-
}, request.headers)
120116
}
121117

122118
if (request.hasBody()) {
123119
options.body = request.getBody();
124120
}
125121

122+
// Set headers after body to allow content-type overrides
123+
options.headers = Object.assign({
124+
"authorization": "Bearer " + this.#apiToken,
125+
"user-agent": this.#userAgent
126+
}, request.headers);
127+
126128
let response;
127129
try {
128130
response = await fetch(url, options);

0 commit comments

Comments
 (0)