-1

There is a free test REST API at https://jsonplaceholder.typicode.com/comments

I've figured out that I can get certain objects by specifying their id like this.

https://jsonplaceholder.typicode.com/comments?id=1

I can also do the same for email. Are more complicated queries possible? What if I wanted to get all objects with ids 1-10, or all objects with a certain word in the body? Could I use something like a logical OR to get all objects with either foo in the name or bar in the body? Can regex be used?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
JSNinja
  • 133
  • 1
  • 9
  • there are reserved characters https://stackoverflow.com/questions/2366260/whats-valid-and-whats-not-in-a-uri-query. how would you pass a regex in your query params – cmgchess Oct 24 '21 at 02:40

1 Answers1

0

you can use https://jsonplaceholder.typicode.com/comments to get all comments and then filter them as you need. axios only takes a url string. So, yes, you can use regex to build that string.Though you can't get object with id 1-10 or use email instead of id if the API doesn't support it.If the API supports it, you can do it.