0

I am using $resource to make a rest api call. My call to that resource is like that :

 Client.get({parametres : param}

My problem is that param contains "\" character, that make the call fail with

400 Bad Request

response.

How can I escape the "\" character?

Thanks.

user1260928
  • 3,269
  • 9
  • 59
  • 105

1 Answers1

0

encodeURIComponent should do the trick.

The encodeURIComponent() method encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).

As per: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

Client.get({ parameters: encodeURIComponent(param) }
Andrew
  • 5,525
  • 5
  • 36
  • 40