Reputation: 4842
I am using Restheart and MongoDB. And I am calling one service(API) for the response data.
Working API
http://127.0.0.1:8080/test/donor?filter="{'name':'john'}"
When I calling above API then it is working, But When I putted API filter is empty, Like filter={} then it is not working.
Not Working API
http://127.0.0.1:8080/test/donor?filter="{}"
When I calling API with empty filter="{}", Then its giving me 400 Bad Request
Actually I wan to achieve one API Call for two purpose.
- One for with filter condition.
- Second one without filter condition.
I want to call Like below.
var qryFilter = {};
var qryFilterParam;
qryFilter["color.code"] = dateInParameter.code;
qryFilterParam = '&filter=' + JSON.stringify(qryFilter)
http://127.0.0.1:8080/test/donor?qryFilterParam
Then some time qryFilterParam have value and some time don't have. When Its have values like filter="{'name':'john'}" then it is working but when it's don't have key value like filter="{}" then it is not working. I am searching solution on website http://restheart.org/curies/1.0/filter.html but I am not able find to solution.
Upvotes: 0
Views: 917
Reputation: 1253
An empty filter is not allowed by restheart.
You need an if statement in your code to make a request with filter qparam and a request without.
Upvotes: 1