I'm trying to use the restapi.js to fetch a user from my rest service. I successfully am making a request but after that I'm getting the error:
"'null' is not an object (evaluating 'item[model.idAttribute]')";from the restapi.js.
My Model:
exports.definition = { config: { URL: "http://192.168.178.40/api/user", //"debug": 1, "adapter": { type: "restapi", collection_name: "users", idAttribute: "id" } }, extendModel: function(Model) { _.extend(Model.prototype, { }); return Model; }, extendCollection: function(Collection) { _.extend(Collection.prototype, { }); return Collection; } };The json response from the request (captured by a network tool):
{"id":1237385,"UserName":"klaasje","UserType":1,"PictureType":2,"PicturePath":"/userimages/401/0_5b7abd22-93ca-4321-be45-cfa8f18cf396_thumb.JPG","PublicUrl":null,"Status":1,"Email":"elger@dp.com","Password":"bla","StatusChanged":"2014-02-20T14:17:05","BirthDate":"1994-01-01T00:00:00","TopicID":79399,"IsFemale":false,"Age":20}The way the request is made:
// get user var model = Alloy.createModel('user',{id: 1237385}); //the fetch method is an async call to the remote REST API. model.fetch({ success : function(){ }, error : function(){ Ti.API.error("hmm - this is not good!"); } });And finally this error:
[ERROR] : Script Error { [ERROR] : backtrace = "#0 () at file:///Users/elgerm/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/6ECCA5FA-C952-4B9D-A36A-A5239FDCE5F4/soichat.app/alloy/sync/restapi.js:34"; [ERROR] : line = 133; [ERROR] : message = "'null' is not an object (evaluating 'item[model.idAttribute]')"; [ERROR] : name = TypeError; [ERROR] : sourceId = 334709920; [ERROR] : sourceURL = "file:///Users/elgerm/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/6ECCA5FA-C952-4B9D-A36A-A5239FDCE5F4/soichat.app/alloy/sync/restapi.js"; [ERROR] : }What am I doing wrong? Am I missing something?