Search code examples
angularjsrestrestangular

Prevent encode the rest call with post Method in Angular js


I am using angular js and making a restcall. But I have one variable and this variable have some value when I put this variable in service then this variable value encoded in console.

REST CALL

var rep = "CX-0138_ES48A9CA";

  Rh.all('example/demo/db ').post(" ",+JSON.stringify(rep)).then(function(resp)
  {
 
  })

then rep value is not exist in console url.

enter image description here

But when I removed +JSON.stringify then service(url) encoded.

var rep = "CX-0138_ES48A9CA";

  Rh.all('example/demo/db ').post(" ",rep).then(function(resp)
  {
 
  })

Encoded service in console
enter image description here

How can set value of rep CX-0138_ES48A9CA in post method.


Solution

  • Try this:

    Rh.all('example/demo/db ').post({rep: encodeUriComponent(rep)}).then(function(resp)
      {
    
      })