Angular 17, possible encode http params on the fly?

96 Views Asked by At

I have an application with quite a few inputs already. When the user enters a special character like an & it results in an API error. Which makes sense given what's being set is something like:

name=bob&title=employee&number=&45

Where number triggers the error. I assumed Angular encoded things like that on it's own but I assumed wrong I guess. I can write a directive to prevent the user from entering specific characters but I'd rather just let them do it and encode special characters.

I thought about grabbing things at an interceptor, encoding, and reconstructing the call but that might be overkill.

Is there a more official or efficient way to encode params on the http call prior to the api request?

0

There are 0 best solutions below