-
Notifications
You must be signed in to change notification settings - Fork 196
Migrate from 1.x to 2.0
Sandro Munda edited this page Feb 26, 2016
·
1 revision
According to this issue https://github.com/SeyZ/jsonapi-serializer/issues/17 we decided to return the json result synchronously instead of a Promise. So, in a nutshell:
var JSONAPISerializer = require('jsonapi-serializer');
new JSONAPISerializer('users', data, {
topLevelLinks: { self: 'http://localhost:3000/api/users' },
dataLinks: {
self: function (user) {
return 'http://localhost:3000/api/users/' + user.id
}
},
attributes: ['firstName', 'lastName']
}).then(function (users) {
// `users` here are JSON API compliant.
});
var JSONAPISerializer = require('jsonapi-serializer');
var users = new JSONAPISerializer('users', data, {
topLevelLinks: { self: 'http://localhost:3000/api/users' },
dataLinks: {
self: function (user) {
return 'http://localhost:3000/api/users/' + user.id
}
},
attributes: ['firstName', 'lastName']
});
// `users` here are JSON API compliant.