Skip to content

Commit 1328270

Browse files
committed
Fix #119: Empty find options for GET requests
1 parent bce6244 commit 1328270

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

classes.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,36 @@ var router = new PromiseRouter();
1010

1111
// Returns a promise that resolves to a {response} object.
1212
function handleFind(req) {
13+
var body = req.method === 'GET' ? req.query : req.body;
1314
var options = {};
14-
if (req.body.skip) {
15-
options.skip = Number(req.body.skip);
15+
if (body.skip) {
16+
options.skip = Number(body.skip);
1617
}
17-
if (req.body.limit) {
18-
options.limit = Number(req.body.limit);
18+
if (body.limit) {
19+
options.limit = Number(body.limit);
1920
}
20-
if (req.body.order) {
21-
options.order = String(req.body.order);
21+
if (body.order) {
22+
options.order = String(body.order);
2223
}
23-
if (req.body.count) {
24+
if (body.count) {
2425
options.count = true;
2526
}
26-
if (typeof req.body.keys == 'string') {
27-
options.keys = req.body.keys;
27+
if (typeof body.keys == 'string') {
28+
options.keys = body.keys;
2829
}
29-
if (req.body.include) {
30-
options.include = String(req.body.include);
30+
if (body.include) {
31+
options.include = String(body.include);
3132
}
32-
if (req.body.redirectClassNameForKey) {
33-
options.redirectClassNameForKey = String(req.body.redirectClassNameForKey);
33+
if (body.redirectClassNameForKey) {
34+
options.redirectClassNameForKey = String(body.redirectClassNameForKey);
3435
}
3536

36-
if(typeof req.body.where === 'string') {
37-
req.body.where = JSON.parse(req.body.where);
37+
if(typeof body.where === 'string') {
38+
body.where = JSON.parse(body.where);
3839
}
3940

4041
return rest.find(req.config, req.auth,
41-
req.params.className, req.body.where, options)
42+
req.params.className, body.where, options)
4243
.then((response) => {
4344
return {response: response};
4445
});

0 commit comments

Comments
 (0)