0

I have this filter:

{ "fields": {"goal":true,"amountPledged": true,"title": true},"where": {"title": {"like":`%${this.state.searchText}%`}} }

The this.state.searchText has value of bio. Which supposedly would be encoded into:

https://website.com/api/table?filter=%7B%20%22fields%22%3A%20%7B%22goal%22%3Atrue%2C%22amountPledged%22%3A%20true%2C%22title%22%3A%20true%7D%2C%22where%22%3A%20%7B%22title%22%3A%20%7B%22like%22%3A%22%25bio%25%22%7D%7D%20%7D

The problem I'm having is the use of % symbol within my filter. This part :

{"like":`%${this.state.searchText}%`}

So, because of that % symbol, my actual encoded link is this, thus causing some error in getting data:

http://website.com/api/table??filter={"fields":{"goal":true,"amountPledged":true,"title":true},"where":{"title":{"like":"%bio%"}}}

How can I make the % symbol to be included & decoded properly?

I'm using Axios to make requests & loopback for my api.

Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53
  • Not sure about how axios does it. but you can implment your own encoding/decoding as an alt solution using [this](http://stackoverflow.com/questions/39116731/how-to-prevent-axios-from-encoding-my-request-parameters) – Panther May 17 '17 at 10:22

1 Answers1

0

I have bumped into this problem aswell, however switched to mongodb where it's not needed when it comes to like-searches.

What solved it for me when using mysql was instead of using "%" using the percent-version of it which is "%25" or escaping "\%".

Undrium
  • 2,558
  • 1
  • 16
  • 24