mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-25 19:23:55 +00:00
return xhr.responseText like everywhere else, try/catch JSON.parse()
Browser tests are failing, I suspect its because it throws when trying to parse response in getResponseData here. //cc @ifedapoolarewaju @goto-bus-stop
This commit is contained in:
parent
8da0874735
commit
ffe9aff17b
1 changed files with 7 additions and 2 deletions
|
|
@ -45,7 +45,12 @@ module.exports = class XHRUpload extends Plugin {
|
|||
* @param {XMLHttpRequest | respObj} responseObject the response object
|
||||
*/
|
||||
getResponseData (responseContent, responseObject) {
|
||||
return JSON.parse(responseContent)
|
||||
try {
|
||||
return JSON.parse(responseContent)
|
||||
} catch (err) {
|
||||
this.uppy.log(err, 'error')
|
||||
return err
|
||||
}
|
||||
},
|
||||
/**
|
||||
*
|
||||
|
|
@ -352,7 +357,7 @@ module.exports = class XHRUpload extends Plugin {
|
|||
timer.done()
|
||||
|
||||
if (ev.target.status >= 200 && ev.target.status < 300) {
|
||||
const resp = this.opts.getResponseData(xhr)
|
||||
const resp = this.opts.getResponseData(xhr.responseText)
|
||||
files.forEach((file) => {
|
||||
this.uppy.emit('upload-success', file.id, resp)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue