jasonkneen / RESTe

A simple JavaScript REST / API helper for Titanium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Model error

icecandy opened this issue · comments

I am using a model with following example code:
var user = RESTe.createModel('user');

user.fetch(
{
success: function(_evt, _response)
{
console.log("User saved!");
console.log(_response);
},
error: function(_evt, _response)
{
console.log("Error saving user!");
console.log(_response);
}
});

I get an error which I believe is related to the code at line 592:

if (results.length === 1) {
options.success(results[0]);
}

This assume results is an array, but it may not be (in my case the returned data is an object). Probably should test for an array but the following does the trick:

if (results.length === 1) {
options.success(results[0]);
}
else
options.success(results);

Cool -- can you submit a PR with your fix if that fixes it. Thanks