POST Form Data as JSON with Fetch API in JavaScript

  Рет қаралды 56,807

ByteGrad

ByteGrad

Күн бұрын

Hi, I'm Wesley. I'm a brand ambassador for Kinde. I'll help you master the latest tech here:
👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
👉 Professional JavaScript Course: bytegrad.com/courses/professi...
👉 Professional CSS Course: bytegrad.com/courses/professi...
👉 Discord: all my courses have a private Discord where I actively participate
🔔 Email newsletter (BIG update soon): email.bytegrad.com
⏱️ Timestamps:
0:00 - Intro
0:37 - Use JavaScript to interact with form
2:22 - Get form data with FormData
3:28 - Convert form data to JavaScript object literal
4:35 - Use fetch() to send data (POST request)
5:30 - Convert data object to JSON
#formdata #fetch #fetchapi #javascript

Пікірлер: 49
@wickedclamor4882
@wickedclamor4882 Жыл бұрын
First time on your channel but I liked it from the start. Great quality, nice audio, clear voice and content is exactly what the title says. Thank you.
@user-mw8fy7en4f
@user-mw8fy7en4f 11 ай бұрын
Man. I am seeing you the first time, and I think you have brilliantly explained the concept. Awesome 💯
@mauricioknabben2793
@mauricioknabben2793 Жыл бұрын
Thank you for all! Greetings from Brasil, this video helped me a lot with a college project
@ByteGrad
@ByteGrad 2 жыл бұрын
Hi, mastering JavaScript is critical if you want to be a modern, professional developer: www.udemy.com/course/professional-javascript-course/?referralCode=0C1D5752923168BC87C2 Also, if you are a front-end developer then mastering CSS (including Flexbox, CSS Grid, etc.) is equally important: www.udemy.com/course/professional-css/?referralCode=4C3C08E82629E6B15752
@ajaygulani3086
@ajaygulani3086 Жыл бұрын
Thank you! this is exactly what I was looking for!
@edwintjoa6099
@edwintjoa6099 Жыл бұрын
Thanks for your video, you made it so easy to understand and implement.
@socialpeople6615
@socialpeople6615 11 ай бұрын
Thank you!!! You helped me figure out the FormData.
@iv4nschneider
@iv4nschneider 8 ай бұрын
Amazing explanation !!! Thank you.
@igorvenancio5899
@igorvenancio5899 Жыл бұрын
You're a really good teacher. Thanks
@Hrit
@Hrit Жыл бұрын
Thanks for such a clear explanation!
@ezechiamaka7293
@ezechiamaka7293 11 ай бұрын
Your video worked and so simple. Thank you so much
@kavindudilshan8818
@kavindudilshan8818 6 ай бұрын
this is the best video i have fond in youtbe for JSON with Fetch API in JavaScript it is very good
@selsabildjazouli7486
@selsabildjazouli7486 9 ай бұрын
that was soo helpful, thank you
@gunnarvispoel581
@gunnarvispoel581 Жыл бұрын
Awesome video, very clear.
@marynakryvoruchenko1393
@marynakryvoruchenko1393 Жыл бұрын
Thanks for the video! Is there a json file that the information gets stored to so I could display it in another file?
@muhamadrifqi2612
@muhamadrifqi2612 Жыл бұрын
Hi, Thank you so much for the amazing tutorial. I have 1 issue, I did the exact same thing, but I get the "crbug/1173575, non-JS module files deprecated." then the page is not working. What could be the issue here?
@troymelok831
@troymelok831 Жыл бұрын
Hi, thanks for sharing. I don´t understand why is needed to convert to json if we can send FormData directly and then in the php file get data with POST if we use this method to send of course
@narendrapatil8407
@narendrapatil8407 Жыл бұрын
Thank you it helped me in my project
@MarcelReig
@MarcelReig Жыл бұрын
Thanks, good video!
@derrickk2916
@derrickk2916 Жыл бұрын
Very helpful!
@032_jatingaur7
@032_jatingaur7 Жыл бұрын
awesome bro💯
@sachinvarma9949
@sachinvarma9949 6 ай бұрын
Thank you so much brotherrr
@MohammadhasanAbbasi
@MohammadhasanAbbasi Жыл бұрын
thank you very much for this video
@JoaqoCR7
@JoaqoCR7 Жыл бұрын
Nice video bro!
@mikempaka6269
@mikempaka6269 8 ай бұрын
Hi ByteGrad, I'm trying to Post from my Api I created in locahost and I have an '''error of SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data". Can it be possible to Post also in API in localhost?
@Onesmo
@Onesmo 4 ай бұрын
thank you so much
@StephaniePena-wq3pe
@StephaniePena-wq3pe 11 ай бұрын
Does this code works if I want to make a form that has to use json information ?
@yeonjoon6637
@yeonjoon6637 Жыл бұрын
Hiii the url u r giving how do I identify how can provide that url!?? Which url nd how can provide it crtly!?
@sharathkk1807
@sharathkk1807 Жыл бұрын
thank you so much sir .
@metifu
@metifu 8 ай бұрын
what about only specific form elements only like "user name" "terms of condition" for the Object?
@sumith
@sumith Жыл бұрын
very usful
@koenstuurman153
@koenstuurman153 Жыл бұрын
Hi, Thanks for the amazing tutorial. I have 1 issue, I did the exact same thing, but I get the "form.html:82 Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')" error. What could be the issue here?
@ByteGrad
@ByteGrad Жыл бұрын
Hi, probably you didn’t select the HTML-element properly with querySelector
@koenstuurman153
@koenstuurman153 Жыл бұрын
@@ByteGrad you're right I used id instead of class hehe. Thanks!
@sinki3322
@sinki3322 8 ай бұрын
When I try to console log my elements, it says « null » and when I try to send them to the api it says « failed to load resource: server responded with 401 ». Do you have ideas on how I could fix it ? Thank you for your video
@ibrohimahmadjonov6859
@ibrohimahmadjonov6859 Ай бұрын
How the page is not reloading after POST method, i cannot do that, please help
@aromalunnikrishnan161
@aromalunnikrishnan161 11 ай бұрын
Thank you sir
@brains4043
@brains4043 4 ай бұрын
hi! theme name?
@valdompinga3790
@valdompinga3790 Жыл бұрын
What if the data to submit is an array of json's? when i send to the backend it gets there on a whole differente format and messes up everything, thank you!
@ByteGrad
@ByteGrad Жыл бұрын
Hi, I don’t know what an array of json’s. You have a code example?
@valdompinga3790
@valdompinga3790 Жыл бұрын
@@ByteGrad Hello thanks for answering, my issue is that im trying to post data to a server that expects a JSON array, an exemple of it is: [{name : "Joe"},{name : "Bill"} ], i tested the endpoint using Insomnia REST, posting an hardcoded JSON array and it works fine, but on the frontend code, the js object is stored in variable because i had to do data pre propressing, so when i posted the data, i did: JSON.stringify(varWithPreprocessedJsObject). What the server recieved it would be equivalent to {[{"name" : "Joe"},{"name" : "Bill"} ]" : ''} So my question is, do identify something i did wrong? Sorry for the long text... thank you!
@ByteGrad
@ByteGrad Жыл бұрын
When you do JSON.stringify() you make it JSON format. Maybe it was already JSON format when you do JSON.stringify()? You would be doubling it
@valdompinga3790
@valdompinga3790 Жыл бұрын
@@ByteGrad BRO, THAT WAS IT! Thank you so much man! Can i follow u on linkedin?
@ByteGrad
@ByteGrad Жыл бұрын
Nice. It’s a common mistake. Sorry don’t have LinkedIn
@Epic_StoriesByPrit
@Epic_StoriesByPrit 6 ай бұрын
can u make vedios on lua luci cause there is very rare material available one internet
@jayroo10
@jayroo10 Жыл бұрын
Hi, are you on UpWork by any chance? as i am trying to fix a piece of code, that needs a "save post" button on the front end, to save response text into a post, it supposed to be straight forward, but I am having trouble with the authenticity token I think, which wont allow the submission to go through. Is there any way to get your help? do you do that kind of thing? thank you
@ByteGrad
@ByteGrad Жыл бұрын
Hi, sorry am completely swamped with work atm
@jayroo10
@jayroo10 Жыл бұрын
@@ByteGrad No worries, and thanks for your reply.
Read JSON File into HTML with JavaScript Fetch API
6:27
ByteGrad
Рет қаралды 36 М.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 43 МЛН
My little bro is funny😁  @artur-boy
00:18
Andrey Grechka
Рет қаралды 13 МЛН
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 96 М.
You don't need a frontend framework
15:45
Andrew Schmelyun
Рет қаралды 108 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,1 МЛН
Sending a form using the FormData object - JavaScript Tutorial
13:10
OpenJavaScript
Рет қаралды 36 М.
Javascript Fetch API With CRUD operations
44:40
Cand Dev
Рет қаралды 63 М.
Save user form input data in a JavaScript object
7:10
OpenJavaScript
Рет қаралды 38 М.
What is a FormData Object
4:42
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 54 М.
Web Developer Roadmap (2024) - Everything is Changing
25:02
ByteGrad
Рет қаралды 293 М.
В России ускорили интернет в 1000 раз
0:18
Короче, новости
Рет қаралды 1,3 МЛН
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
ЗЕ МАККЕРС
Рет қаралды 165 М.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 3,5 МЛН