POST form data using JavaScript's Fetch API

preview_player
Показать описание

Form data can be sent via JavaScript's Fetch API by converting the form element into a FormData object or a URL-encoded string and specifying this as the body of the fetch request.
#javascript #fetch #fetchapi #httprequest #formdata #api

⚡ NEW: Web development courses from Meta Inc. ⚡

Рекомендации по теме
Комментарии
Автор

One important detail that you didn't mention is that each imput has to have a name attribute (with a value) to be included in the formData element, otherwise it skips it

whatisthis__
Автор

This helped me solve the problem I've been facing for a long time now, thank you very much.

tolorunseelizabeth
Автор

Excellent explanation, dude!
Thanks!
Forte abraço!

viniciusm.m.
Автор

Wow awesome I have been looking for something like this for a while now. Thanks alot

kodenigga
Автор

thanks. i was getting frustated with the content type, when i fetch the FormData to a servlet it came out empty, just adding URLSearshParam made it work.

Investigador
Автор

I really like your videos, ...but your Mic volume its reallly low !!!

romimaximus
Автор

any complete tutorial for posting to database a form data with image attachment??

j.nmwaniki
Автор

Thanh you for the video. I would like to know if you have any video talking about the formdata object and ajax?

tiagoborges
Автор

I copy pasted the same code but its showing error at this point
form.addEventListener('submit', function(e) {

krishnajoshi
Автор

I have all input data saved in local storage and want to send it. Is there any way to send formdata from there

nikolozdvali
Автор

Great code but i get the error:Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
at fetch_api.js:5:6
(anonymous) @ fetch_api.js:5

zachfenton