Skip to content

Commit

Permalink
Fixed errors not being parsed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
masylum committed Aug 27, 2016
1 parent 4ebf8e1 commit 34d0ca1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ function ajax (url: string, options: {}): Request {

const promise = new Promise((resolve, reject) => {
xhr
.then(resolve)
.fail((jqXHR, textStatus) => reject(textStatus))
.done(resolve)
.fail((jqXHR, textStatus) => {
return reject(
JSON.parse(jqXHR.responseText).errors || {}
)
})
})

const abort = () => xhr.abort()
Expand Down
10 changes: 5 additions & 5 deletions src/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class Model {

return data
})
.catch((body) => {
this.request = null
this.attributes = asMap(originalAttributes)
this.error = {label, body}
})
.catch((body) => {
this.request = null
this.attributes = asMap(originalAttributes)
this.error = {label, body}
})
}

@action destroy (
Expand Down

0 comments on commit 34d0ca1

Please sign in to comment.