mafortis
mafortis

Reputation: 7138

Angular API call with double quotation marks

I have service where I call API URL and my URL supposed to have ".." quotation mark around my values but it prints like %22%27 when I call the API, How can I have my double quotation marks as they are in my URL?

Code

return this.http
      .get(`${this.env.HELPDESK_LIST_FILTER}` + '[{ "value": ' + `'"${value}"'` + ', "field": ' + `'"${column}"'` + ', "sort": ' + `'"${sort}"'` + ', "op": ' + `'"${filter}"'` + ' }]', params)
      .pipe(map((data) => data));

My final URL supposed to be like this:

https://example.com/api/tickets?filters=[{"value":"una","field":"name","sort":"none","op":"like"}]

Instead it's like this now:

https://example.com/api/tickets?filters=[{%20%22value%22:%20%27%22una%22%27,%20%22field%22:%20%27%22name%22%27,%20%22sort%22:%20%27%22none%22%27,%20%22op%22:%20%27%22like%22%27%20}]

Any idea?

Upvotes: 3

Views: 977

Answers (1)

sonEtLumiere
sonEtLumiere

Reputation: 4572

Try this:

    return this.http
          .get(`${this.env.HELPDESK_LIST_FILTER}[{ "value": "${value}", "field": "${column}", "sort": "${sort}", "op": "${filter}" }]`, params)
          .pipe(map((data) => data));

Upvotes: 1

Related Questions