Today I learned

July 23, 2021

Encoding POST request body

Today I learned, that passing unencoded text into the body of a POST request is a bad idea. It could result in security issues and therefore always should be encoded.

One approach to resolve this is using URLSearchParams. You can learn more about the API on mdn: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

Jake Archibald wrote a blog post about this topic, where he explains it in more depth: https://jakearchibald.com/2021/encoding-data-for-post-requests

Greetings Marco

Go back to other today-I-learned posts