diff --git a/src/Api.js b/src/Api.js index bcf526e..725e7ff 100644 --- a/src/Api.js +++ b/src/Api.js @@ -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() diff --git a/src/Model.js b/src/Model.js index 0879cf3..dae3572 100644 --- a/src/Model.js +++ b/src/Model.js @@ -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 (