From a4f7e07b3bf2ce297fe8c0898710f88d141ece85 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sun, 8 Mar 2020 19:28:19 +0100 Subject: [PATCH] fix(APIRequest): only use form data when actually sending files (#3917) --- src/rest/APIRequest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index d94f0e65a..3a9d6294a 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -39,7 +39,7 @@ class APIRequest { if (this.options.headers) headers = Object.assign(headers, this.options.headers); let body; - if (this.options.files) { + if (this.options.files && this.options.files.length) { body = new FormData(); for (const file of this.options.files) if (file && file.file) body.append(file.name, file.file, file.name); if (typeof this.options.data !== 'undefined') body.append('payload_json', JSON.stringify(this.options.data));