fix(APIRequest): only use form data when actually sending files (#3917)

This commit is contained in:
SpaceEEC
2020-03-08 19:28:19 +01:00
committed by GitHub
parent 79a28b55a8
commit a4f7e07b3b

View File

@@ -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));