Sudhir Shrestha Sudhir Shrestha - 7 months ago 157
Javascript Question

How can ember application be integrated to use with json-server?

I am starting out fresh into ember.js. I have started out with developing a basic RESTful application using json-server as the data server.

After going through number of documentations, It seems ember has standardized a format for JSON response format from the server and is incompatible with "json-server" by itself.

Is there any possibility of handling this in the ember side ?

Ember version: 1.13

Here is my current error log:

ember.debug.js:30195 Error while processing route: tasks.index Assertion Failed: normalizeResponse must return a valid JSON API document:
* One or more of the following keys must be present: "data", "errors", "meta". Error: Assertion Failed: normalizeResponse must return a valid JSON API document:
* One or more of the following keys must be present: "data", "errors", "meta".
at new Error (native)

Answer

Place this in app/serializers/application.js

import DS from 'ember-data';

export default DS.JSONSerializer;