Pass x-www-form-urlencoded Data In Angular

We have got different types of pre-defined Content-Type for sending data in the body of the request. Let's see how can we use application/x-www-form-urlencoded for sending data in angular typescript.

Firstly, let's understand why we need application/x-www-form-urlencoded for sending data?

It is required mainly to secure data transmission over the network. It poses no security risk. This Content-Type is usually used as a part of form submission. So, all the security risks apply to HTML form need to consider using this Content-Type.

When we pass data, it becomes key, value separated by '&' when there are multiple data.

Now let's see, how we pass data for Content-Type application/x-www-form-urlencoded in typescript.

We use class URLSearchParams() in typescript as depicted in the image below.