I am attempting to submit invalid data via a POST
request to a JSONAPI-based API with Ember Data 2.10. The API responds correctly with a 422
code and this payload in the response:
{
"errors": [{
"title": "Title can't be blank",
"id": "title",
"code": "100",
"source": {
"pointer": "/data/attributes/title"
},
"status": "422"
}, {
"title": "Layout can't be blank",
"id": "layout",
"code": "100",
"source": {
"pointer": "/data/relationships/layout"
},
"status": "422"
}, {
"title": "Page type can't be blank",
"id": "page-type",
"code": "100",
"source": {
"pointer": "/data/attributes/page-type"
},
"status": "422"
}]
}
The errors seem to be loading mostly OK into the model, but I get this error in the console:
ember.debug.js:19160 Error: The adapter rejected the commit because it was invalid
at ErrorClass.EmberError (ember.debug.js:19083)
at ErrorClass.AdapterError (errors.js:23)
at ErrorClass (errors.js:49)
at Class.handleResponse (rest.js:821)
at Class.handleResponse (data-adapter-mixin.js:100)
at Class.superWrapper [as handleResponse] (ember.debug.js:24805)
at ajaxError (rest.js:1342)
at Class.hash.error (rest.js:916)
at fire (jquery.js:3305)
at Object.fireWith [as rejectWith] (jquery.js:3435)
What is causing this error? Is there something wrong in the JSON payload being returned by the server? One thing that changed recently was the introduction of a pointer to /data/relationships/layout
; is Ember Data choking on that?
I may also note that submitting similar bad data via a PATCH
request does not trigger this error in the console.
I've also tried this on Ember Data 2.7 before updating to 2.10 to see if that would fix it. Getting the same error with both versions.
Aucun commentaire:
Enregistrer un commentaire