We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3e91a94 + 9e22b5f commit 63f2d90Copy full SHA for 63f2d90
src/WebHelper.js
@@ -161,6 +161,17 @@ class WebHelper extends Helper {
161
if (err || Math.floor(resp.statusCode / 100) !== 2) {
162
return reject(err || resp.statusCode);
163
}
164
+ // xhr makes it difficult to both send FormData and automatically
165
+ // parse a JSON response. So try to parse everything as JSON.
166
+ if (typeof body === 'string') {
167
+ try {
168
+ body = JSON.parse(body);
169
+ } catch (parseError) {
170
+ // If it's not parseable, then we can't add the id even
171
+ // if we want to, so stop here
172
+ return resolve(body);
173
+ }
174
175
return resolve(Object.assign({
176
id: body['content-name'] || assetId
177
}, body));
0 commit comments