Merge pull request #120 from GigabyteTheOne/master
Fix #119: Empty find options for GET requests
This commit is contained in:
33
classes.js
33
classes.js
@@ -10,35 +10,36 @@ var router = new PromiseRouter();
|
|||||||
|
|
||||||
// Returns a promise that resolves to a {response} object.
|
// Returns a promise that resolves to a {response} object.
|
||||||
function handleFind(req) {
|
function handleFind(req) {
|
||||||
|
var body = Object.assign(req.body, req.query);
|
||||||
var options = {};
|
var options = {};
|
||||||
if (req.body.skip) {
|
if (body.skip) {
|
||||||
options.skip = Number(req.body.skip);
|
options.skip = Number(body.skip);
|
||||||
}
|
}
|
||||||
if (req.body.limit) {
|
if (body.limit) {
|
||||||
options.limit = Number(req.body.limit);
|
options.limit = Number(body.limit);
|
||||||
}
|
}
|
||||||
if (req.body.order) {
|
if (body.order) {
|
||||||
options.order = String(req.body.order);
|
options.order = String(body.order);
|
||||||
}
|
}
|
||||||
if (req.body.count) {
|
if (body.count) {
|
||||||
options.count = true;
|
options.count = true;
|
||||||
}
|
}
|
||||||
if (typeof req.body.keys == 'string') {
|
if (typeof body.keys == 'string') {
|
||||||
options.keys = req.body.keys;
|
options.keys = body.keys;
|
||||||
}
|
}
|
||||||
if (req.body.include) {
|
if (body.include) {
|
||||||
options.include = String(req.body.include);
|
options.include = String(body.include);
|
||||||
}
|
}
|
||||||
if (req.body.redirectClassNameForKey) {
|
if (body.redirectClassNameForKey) {
|
||||||
options.redirectClassNameForKey = String(req.body.redirectClassNameForKey);
|
options.redirectClassNameForKey = String(body.redirectClassNameForKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof req.body.where === 'string') {
|
if(typeof body.where === 'string') {
|
||||||
req.body.where = JSON.parse(req.body.where);
|
body.where = JSON.parse(body.where);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rest.find(req.config, req.auth,
|
return rest.find(req.config, req.auth,
|
||||||
req.params.className, req.body.where, options)
|
req.params.className, body.where, options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return {response: response};
|
return {response: response};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user