Using the Fetch API with URLSearchParams in JavaScript

preview_player
Показать описание
The new URLSearchParams Object integrates really well with the Fetch API. In this video I'll be going over how you can easily combine the use of these two JavaScript features.

We'll be making two types of requests, a GET request and a POST request. To construct the data to be sent with these requests, we'll use the URLSearchParams Object.

Combining these two with a POST request discovers the real benefits of the Fetch API as it automatically sets the Content-Type header for you, something that is not provided with typical AJAX requests when sending url-encoded form data.

Support me on Patreon:

For your reference, check this out:

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

Im learning fetch, and I found URLSearchParams... beautiful how these tools can work together in a real application!
Thank you very much for the video, great help :)

kunamate
Автор

I didn't know about this, thanks for the video.

keinermendoza
Автор

wow almost two years learning web dev and have NEVER been taught this URLsearch params way of doing things. holy shit lol

BobbyBundlez
Автор

Thanks, I am using APIs a lot more but still focus on backend stuff. Funny how much work it takes to hook everything up without it being fragile and inflexible

FINSuojeluskunta
Автор

Thanks for this useful video, i was looking for such thing for hours.

ashkanzargham
Автор

thank you of helping out, didn't knew this could work here . ;)

immortal
Автор

You're a life saver! Thank you very much :D

ventus
Автор

Thanks for switching to dark!! So much nicer!

unachoza
Автор

Seems like darn IE still doesn't support it in 2021

pavelkulinich