I'm really new to ember and I'm trying to send a JSON data with my REST backend (I'm using Django REST framework with Django JSON API), but I'm getting some weird errors.
Error:
1)Error while processing route: sampledata.index serializer.normalizeResponse is not a function
normalizeResponseHelper@http://localhost:4200/assets/vendor.js:77763:30....
2)normalizeResponseHelper@http://localhost:4200/assets/vendor.js:77763:30
_findAll/</<@http://localhost:4200/assets/vendor.js:77625:24
Backburner.prototype.run@http://localhost:4200/assets/vendor.js:10805:18....
My data sent is:
{
"links": {
"first": "http://localhost:8000/api/sampledata?page=1",
"last": "http://localhost:8000/api/sampledata?page=1",
"next": null,
"prev": null
},
"data": [{
"type": "sampledata",
"id": "4",
"attributes": {
"blind_id": "1-146788",
"aliquots_circulation": 9,
"total_dna": 120,
"data_type": "WES"
},
"relationships": {
"projects": {
"data": [],
"meta": {
"count": 0
}
}
}
}],
"meta": {
"pagination": {
"page": 1,
"pages": 1,
"count": 1
}
}
}
My ember model (/app/models/sampledata.js):
import DS from 'ember-data';
export default DS.Model.extend({
blind_ID: DS.attr('string'),
aliquotsCirculation: DS.attr('number'),
totalDna: DS.attr('number'),
dataType: DS.attr('string'),
projects: DS.hasMany('project')
});
My adapter (/app/adapters/application.js):
import DS from 'ember-data';
import ENV from 'frontend/config/environment';
export default DS.JSONAPIAdapter.extend({
host: ENV.host,
namespace: 'api'
});
My serializer (/app/serializers/application.js)
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
});
If I change my serializer to
export default DS.RESTSerializer.extend({
primaryKey: '_id',
serializeId: function(id) {
return id.toString();
}
});
I get the following WARNINGS and NO ERRORS, but no data is shown:
WARNING: Encountered "links" in payload, but no model was found for model name "link" (resolved model name using frontend@serializer:application:.modelNameFromPayloadKey("links"))
vendor.js (line 16826)
WARNING: Encountered "data" in payload, but no model was found for model name "datum" (resolved model name using frontend@serializer:application:.modelNameFromPayloadKey("data"))
Aucun commentaire:
Enregistrer un commentaire