From 3d4b2a3f9142f60e25358ac11af995ef5a451749 Mon Sep 17 00:00:00 2001 From: Simon Buckingham Date: Mon, 20 Aug 2018 13:02:45 +0100 Subject: [PATCH] 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