I have a Rails backend that would serve JSONs like this: (This e.g. is 2.json)
{"id":2,"name":"Magic","location":"Cyberjaya","surprise_type":"Great","instructions":"test","status":"awesome","pricing_level":3,"longitude":"2.90873","latitude":"101.655027","created_at":"2016-02-02T07:19:18.247Z","updated_at":"2016-02-02T12:59:14.403Z"}
and an AngularJS app.js code that goes like this (the relevant parts only):
.factory('MarkersLoc', function($resource) {
debugger;
return $resource("http://localhost:3000/surprises/:id.json");
})
.factory('Markers', function(MarkersLoc) {
var markers = [];
return {
getMarkers: function(){
return MarkersLoc.query().$promise.then(function(response){
debugger;
markers = response;
console.log("Markers: ", markers);
return markers;
});
}
}
})
The problem that I'm having is that, even at the point of the debugger, response is an array of objects that have all the attributes from the JSON except longitude, latitude, created_at and updated_at.
Unfortunately I am unable to determine the reason why these four key-value pairs are omitted when it's being read and returned. Is there something that should be controlling which key-value pair is being processed that I have left out on? Wouldn't the entire JSON be parsed and converted into the object?
*_serializer.rb. - gnerkusclass SurpriseSerializer < ActiveModel::Serializerattributes :id, :name, :location, :surprise_type, :instructions, :status, :pricing_levelendI will try changing this file and get back on if it is the cause of it - Joel Lim