0

In GET API I have value as,

title=my&title

where the value from query param title returns only my and splits from & character.

Can anyone help me with how can I include & in my value?

RHF
  • 17
  • 6
  • Does this answer your question? [Should an ampersand be URL encoded in a query string?](https://stackoverflow.com/questions/41907682/should-an-ampersand-be-url-encoded-in-a-query-string) – Phu Ngo Apr 14 '21 at 08:44

1 Answers1

0

Your query parameters should be URL-encoded in order to differenciate a separating & from a random character.

The solution is to encode the value before sending it through the request. You can do so by passing your value to encodeURIComponent(). You can then parse it the same way and decode it using decodeURIComponent(), e. g. :

encodeURIComponent('my&title') -> 'my%26title'
decodeURIComponent('my%26title') -> 'my&title'
Arthur Chaloin
  • 610
  • 1
  • 5
  • 12