-1

I am unable to send "id" in following scenario.
Ex: url=somedomain/{id}/emp For this I set the url in proxy.config.json file as

"/employee": {
  "target":"somedomain",
  "secure":false,
  "pathReWrite: {
    "/employee":""
  }
}

Now in the Angular Service file I am calling as

this.http.post(`http://localhost:4200/employee/{id}/emp`);

in this case the total url is replaced with /employee only. But I want to send "id" dynamically through proxy.config.js file. Could you please help me out how to resolve this issue? Thanks in advance.

yurzui
  • 205,937
  • 32
  • 433
  • 399
hari
  • 103
  • 1
  • 2
  • 8

1 Answers1

0

I guess you have a typo.

Replace capital W with w in pathReWrite:

   should be w
       \/
"pathReWrite: {
  "/employee":""
}
yurzui
  • 205,937
  • 32
  • 433
  • 399
  • I tried with that too.. It’s not working with dynamic id – hari Oct 13 '20 at 15:12
  • What do you mean with dynamic id? If you send `/employee/3/emp` it will rewrite to `somedomain/3/emp`, `/employee/9/emp` => `/somedomain/9/emp` etc – yurzui Oct 13 '20 at 15:48
  • But it’s rewriting the total url from angular service. If I give id in the url, its replacing with proxy config url.. btw I am appending id in service to url like proxy url + id. – hari Oct 13 '20 at 15:54
  • It doesn't matter how you're combining url – yurzui Oct 13 '20 at 16:02