0

I need to call rest api for example:

let developerId ="123#212";
let url = `${Constants.BASE_URL}${marketId}/developers/${developerId}`;
return this.http.get(url);

But backend only getting 123 instead of 123#212

What I tried so far is to do but not working

Calling the rest api using Postman perfectly working but not in Angular

richersoon
  • 4,682
  • 13
  • 44
  • 74

1 Answers1

0

Instead of sending this with hashtag use HttpParams to send this data you can see the same being used in the question you mentioned.

In your post/get request you can add this

this.http.get('URL', {
      params: new HttpParams()
        .set('param-a', 'value-1')
        .set('param-2', 5)
    })
Nishant
  • 821
  • 7
  • 17
  • HttpParams is for query parameter right? But the hastag is part of URL not query parameter – richersoon Jun 03 '21 at 10:58
  • Yes but when you want to send data to backend it should be sent using Params or Headers, also looks like # data is for browsers only & even if you encode you would still need to send it as a param or it would just act as a different URL. Check this https://stackoverflow.com/a/3664324/1731150 – Nishant Jun 03 '21 at 11:19