From e42f201b8b0af8b3f2615abe8161c8087f52f1b2 Mon Sep 17 00:00:00 2001 From: jake champion Date: Sat, 27 Feb 2021 18:40:39 +0000 Subject: [PATCH] Revert "Represent non-stringified JSON request body as an [object Object] string" This reverts commit 5c6b055e6ae6f718f416c94bfcdc89693d0abdcb. --- fetch.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fetch.js b/fetch.js index d298ef77..5050a247 100644 --- a/fetch.js +++ b/fetch.js @@ -246,9 +246,7 @@ function Body() { this._bodyText = body = Object.prototype.toString.call(body) } - var contentType = this.headers.get('content-type') - - if (!contentType) { + if (!this.headers.get('content-type')) { if (typeof body === 'string') { this.headers.set('content-type', 'text/plain;charset=UTF-8') } else if (this._bodyBlob && this._bodyBlob.type) { @@ -256,10 +254,6 @@ function Body() { } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') } - } else if (contentType.indexOf('json') >= 0 && typeof this._bodyInit !== 'string') { - // Always pass a text representation of a non-stringified JSON body - // to `XMLHttpRequest.send` to retain a compatible behavior with the browser. - this._bodyInit = this._bodyText } }