V SH V SH - 8 months ago 44
AngularJS Question

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.

Answer Source

Try this:

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

  })
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download