From 3d4b2a3f9142f60e25358ac11af995ef5a451749 Mon Sep 17 00:00:00 2001 From: Simon Buckingham Date: Mon, 20 Aug 2018 13:02:45 +0100 Subject: [PATCH 1/3] Fixes bug where using a model only (with no collection) and the api returns an object say, rather than an array. --- reste.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/reste.js b/reste.js index 0636f1d..c4c86bb 100644 --- a/reste.js +++ b/reste.js @@ -587,10 +587,15 @@ var main = function() { if (modelConfig.content) { - var results = e[modelConfig.content]; + var result = e[modelConfig.content]; - if (results.length === 1) { - options.success(results[0]); + if (result.length === 1) { + //result is an array with value as first entry + options.success(result[0]); + } + else { + //result is not an array + options.success(result); } } else { // calls error handler if we have it defined and 201+ returned From 467ef2a2d7cd96dd226ad9616095ee5d6d23fa60 Mon Sep 17 00:00:00 2001 From: Jason Kneen Date: Mon, 3 Sep 2018 18:24:06 +0100 Subject: [PATCH 2/3] Update readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 2af4b4d..5dba0c0 100644 --- a/readme.md +++ b/readme.md @@ -462,13 +462,13 @@ Using the following config you can configure end points that will still work as get: 'classes/locations?where={"name": ""}' }, { name: "updateLocation", - put: "classes/locations/" + put: "classes/locations/" }, { name: "createLocation", post: "classes/locations/" }, { name: "deleteLocation", - delete: "classes/locations/" + delete: "classes/locations/" }] ``` From 9b625260df709c69d49298f29ca46fafa98397e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?brian=20garci=CC=81a?= Date: Sat, 1 Dec 2018 21:11:15 +0100 Subject: [PATCH 3/3] return the HTTPClient to allow abort the call --- reste.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reste.js b/reste.js index 0636f1d..eeb644a 100644 --- a/reste.js +++ b/reste.js @@ -158,7 +158,7 @@ var main = function() { function retry() { log('Retrying...'); - makeHttpRequest(args, onLoad, onError); + return makeHttpRequest(args, onLoad, onError); } var error; @@ -226,7 +226,7 @@ var main = function() { } else { send(); } - + return http; } // set Requestheaders @@ -338,7 +338,7 @@ var main = function() { } }); - makeHttpRequest({ + return makeHttpRequest({ url : url, method : method, params : body, @@ -370,7 +370,7 @@ var main = function() { throw 'RESTe :: missing parameter/s ' + missing + ' for method ' + args.name; } else { - makeHttpRequest({ + return makeHttpRequest({ url : url, method : method, params : body,