lundi 29 janvier 2018

Ember JS: Assertion Failed: `AdapterError` expects json-api formatted errors array

I am making my first Ember/Phoenix app using JSONAPIAdapter. When doing a post request Ember responds with Assertion Failed: AdapterError expects json-api formatted errors array.

Below is the relevant code:

adapter/application.js

import DS from 'ember-data';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
import config from '../config/environment';

export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {

});

serializers/application.js

import DS from 'ember-data';

export default DS.JSONAPISerializer.extend({

});

request payload:

{
    "data": {
        "attributes": {
            "name": ""
        },
        "relationships": {
            "user": {
                "data": {
                    "type": "users",
                    "id": "1"
                }
            }
        },
        "type": "listings"
    }
}

response payload:

{"errors":{"name":["can't be blank"]}}

Why does Ember keeps giving me this error?




Aucun commentaire:

Enregistrer un commentaire