0

I've created a sample app using Angular4 and ASP.NET WebApi. While sending a POST request I'm escaping html signs in C# this way.

Regex.Replace(val,"&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;");

And that works fine. The thing is, I'd like to change all occurrences of (& < > and so on...) again while GET request is done instead of serving users texts like 'm & m's'.

I've learnt that should be done using angular interceptor, but couldn't find any example.

What I have is this piece of code to handle GET requests from API.

getJson(url: string): Observable<any> {


    return this.http.get(JsonEndpoint + url, { withCredentials: true })
        .map(result => {
            return result.json();

              // here I could do a replace function like
              // result .replace('&amp;', '&')
              // but it does not work

        })
        .catch(this.handleError);


}

Thanks!

tylkonachwile
  • 1,405
  • 2
  • 11
  • 22

0 Answers0