1

I am working with Parse Server, and I am trying to fetch data using the REST API in my Angular2 application.

I am trying to fetch data according to a where condition, but I am not able to do so.

This is the code I am using:

  constructor(http) {
        var key = new URLSearchParams();
        this.http = http;
        this.disho = null;

        key.set('where', {"estTime":"5min"});
        this.http.get('https://parseapi.example.com/classes/Setto', { where : key }).subscribe(data => {
        this.disho = data.json().results;
        console.log(this.disho);
        });

      }

The above code ignore my where condition, and returns all the records.

However, the following code returns the right results when executed in terminal via cURL

curl -X GET \
-H "X-Parse-Application-Id: someKey" \
-H "X-Parse-REST-API-Key: someKey" \
-G \
--data-urlencode 'where={"estTime":"5min"}' \
https://parseapi.example.com/classes/Setto
2
  • 1
    I assume you've ruled out a server-side problem here? if so, open network panel in dev tools and see if the params actually being passed are what you expect Commented May 1, 2016 at 5:12
  • Could you give us a plunkr? Commented May 1, 2016 at 7:02

2 Answers 2

2

Change { where : key } to { search : key }

Should work!

Sign up to request clarification or add additional context in comments.

Comments

1

I think that there is a typo in your code. Single quotes are missing. You could try the following:

key.set('where', '{"estTime":"5min"}');

1 Comment

your solution is 50% of the real solution :D I made it fully working by changing { where : key } to { search : key } in addition to the solution you proposed! Anyway, thank you ! ++1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.