Let's say that my filter condition results in empty resultset. My _embedded array is empty. Now I want to add a custom response instead of empty response. When I used a custom response transformer, I am not able to add a custom response. I am able to add only an additional property like _returned. But the problem is I always use "np" with the query so my custom property is removed.
Asked
Active
Viewed 38 times
1 Answers
0
np stands for No Properties, meaning that the requesters is asking restheart not to return the collection properties and just the embedded documents.
My suggestion is that if you need your custom collection properties you shouldn't use np.

Andrea Di Cesare
- 1,125
- 6
- 11
-
Hi..Thanks..I want to set a custom response when there is no response from DB. Can you help with that ? For eg: if my filter returns no document, I need to set a custom error response saying "member not found", "document not found" etc – RDR Jan 27 '18 at 16:28
-
You can use a transformer, just don't add np qparam to the request url – Andrea Di Cesare Jan 27 '18 at 18:00
-
Thanks again.Can I change the http response code as well? If there is no data, I have to change the http status code to 404. Also, if i do not give np, many properties are visible in the response. But I need only my custom error response to be visible. Is there a way for this ? – RDR Jan 29 '18 at 21:11