Why does JavaScript's fetch make me wait TWICE?

  Рет қаралды 234,919

Tom on the Internet

Tom on the Internet

Күн бұрын

Пікірлер: 528
@hyperprotagonist
@hyperprotagonist 3 ай бұрын
Damn this video is everywhere. Algorithm is on your side.
@tomontheinternet
@tomontheinternet 3 ай бұрын
Yeah. I don’t know why. It had 100 views after the first 24 hours and then it exploded.
@hyperprotagonist
@hyperprotagonist 3 ай бұрын
@@tomontheinternetwell, I’m glad it did. You just earned another subscriber 🎉
@cdruc
@cdruc 3 ай бұрын
@@tomontheinternet because it's great! it's straight to the point and answers something *many* people were wondering but never took the time to find out why/how it happens :D
@TheBuilder
@TheBuilder 3 ай бұрын
@@tomontheinternet It's a strange, easy to understand question with a simple to the point thumbnail.
@etexas
@etexas 2 ай бұрын
@@tomontheinternet I got this video recommended to me as well just now
@Ligma_Shlong
@Ligma_Shlong 3 ай бұрын
tldw the first await just waits for headers, then the second waits for the body, because its parsing a response stream (bytes come in incrementally) not the entire payload at once
@tomontheinternet
@tomontheinternet 3 ай бұрын
That’s right Ligma Schlong!
@sulaimanshabbir
@sulaimanshabbir 3 ай бұрын
❤❤
@waldolemmer
@waldolemmer 3 ай бұрын
Thanks, Ligma Shlong. It's what I suspected, but the HTTP hint at the start threw me off
@rakha8812
@rakha8812 3 ай бұрын
Thank you Ligma Shlong!
@meyegui
@meyegui 3 ай бұрын
Ligma Shlong da real MVP
@theyayaa
@theyayaa 3 ай бұрын
Before you attack this man, please, AWAIT...he is a good man
@abdelrahmanhafez990
@abdelrahmanhafez990 3 ай бұрын
I can tell he's a good man almost right away, but I needed to await to see what his content looks like.
@d.156
@d.156 3 ай бұрын
.then(() => "I agree")
@antonpieper
@antonpieper 3 ай бұрын
@@theyayaa nah, I had to Text decode his stream
@ArturDani
@ArturDani 3 ай бұрын
not just once but twice, AWAIT... AWAIT...
@r-i-ch
@r-i-ch 3 ай бұрын
Do you Promise?
@shableep
@shableep 2 ай бұрын
Summary: The first await: When you call fetch, it returns a promise that resolves as soon as the server responds with headers. This happens quickly, before the full response body is received. At this point, you only have access to the response metadata (like status code and headers). The second await: To get the actual response body content, you need to call a method like response.json(). This method also returns a promise, because the body content might still be streaming in from the server. The response body can be much larger than the headers and, in some cases, might take significant time to fully download.
@TheBswan
@TheBswan 3 ай бұрын
This is great. Love the node server with no framework, and the UI with code snippets during demo. Learned two new things (headers arrive before body + how simple streaming responses can be) in 6 minutes. Really nice job here, thank you!
@tomontheinternet
@tomontheinternet 3 ай бұрын
Glad you like that. I really enjoy how much you can do without pulling in libraries, especially for demonstration apps.
@thomasle100
@thomasle100 3 ай бұрын
​@@tomontheinternetI agree! And we can do a lot with vanilla js in the frontend without frameworks :)
@beaucranston9586
@beaucranston9586 3 ай бұрын
Don't ACTUALLY stream data like this. This was just a demonstration about how HTTP works. If you need live stream data, use a pipe (websocket, grpc, etc). Still a great video though.
@vryaboshapko
@vryaboshapko 3 ай бұрын
> headers arrive before body This thing was quite a big pain in the neck for PHP developers back in times when I used to handle with it 😵‍💫 Just a portion of flashbacks.
@Kriszzzful
@Kriszzzful 2 ай бұрын
@@vryaboshapko story time?
@mjdev-i1p
@mjdev-i1p 3 ай бұрын
dude is doing the lords work fighting against JS-Terminators
@Digitalgems9000
@Digitalgems9000 2 ай бұрын
haha
@ColinRichardson
@ColinRichardson 3 ай бұрын
Just to note, you don't actually send your headers until line 34 of your server code. the first instance of `res.write()` if you wanted to be sure you send the headers before the first body write, you will want `res.flushHeaders()` at that point the headers are locked and available for sending down the wire. `res.write()` ensures this internally also, but you are doing that 2ms after finalising your headers in your setInterval.
@tomontheinternet
@tomontheinternet 3 ай бұрын
Thank you. I didn’t know that. Makes sense!
@ColinRichardson
@ColinRichardson 3 ай бұрын
@@tomontheinternet You can check this yourself by making your interval be say 10 seconds, and then you will notice that your "got response" console log is a lot later than "got it instantly".
@ivandamyanov
@ivandamyanov 3 ай бұрын
This basically means that without flushHeaders, the first response is only sent when the first part of the body is written and that's when the headers will be included, right?
@ColinRichardson
@ColinRichardson 3 ай бұрын
@@ivandamyanov correct, delaying it til the writing of the body, allows you time to add (and potentially remove) headers from the header section until the last possible moment. EG: as the body is being sent. Once the body is being sent, all opportunity to modify the headers are gone. They are already sent.. Too late.. better luck next time. But, sometimes it's advantageous to send the headers early (with flushHeaders), while the body is still not ready to be sent. Though, these examples are few and far between. The only times I can think of off the top of my head, was using multipart image-replace, which was a dirty way of doing webcam streams, and the other example was sending a large zip file, but we purposely added a delay so the recipient client could read some custom headers, and decide to abort the connection before we actually started the zipping process, so not to waste server resources.. I am sure there are more examples, but I am getting old and those are the ones that come to mind right now..
Ай бұрын
@@ivandamyanov `writeHead()` only fills property of object (adds value to `Resonse.Headers[]` or whatever type that property is). `Response.flushHeaders()` and `Response.write` have actually trigger sending the response object
@charithaJayabahu
@charithaJayabahu 3 ай бұрын
Bro went deep but explained everything crystal clearly. Hope you make more videos like this. Hats off.
@UliTroyo
@UliTroyo 3 ай бұрын
Dang, what an illustrative demo.
@blarvinius
@blarvinius 3 ай бұрын
I love this kind of DETAILED explanation ❤
@69k_gold
@69k_gold 3 ай бұрын
This actually opens way to a super cool optimization. If the status code is not 2XX, there's a chance some APIs return an entire web page (like Microsoft Azure with 503 errors) waiting to retrieve that entire self-sufficient HTML document is such a waste of time. Rather, you can then flush it out and carry on with your other tasks
@Georgggg
@Georgggg 3 ай бұрын
I doubt, that would give you anyhting in practice. Rule of thumb is 14kb per request, which will sent per 1 tcp round trip anyway, regardless if it is 1kb, or 10kb.
@micheloe
@micheloe 3 ай бұрын
​@@Georgggg Ethernet maximum transmission unit (MTU) is 1500 bytes. With TCP on top you get 1460 bytes, which is roughly 1.4kB and usually what you see flying around on the internet as well. That is nowhere near the 14k you mention. Where did you get that number from? There is something called jumbo frames, which ups the MTU to 9000 bytes, but that usually doesn't extend to the internet.
@eneg_
@eneg_ 3 ай бұрын
Perhaps the difference lies in b vs B
@callowaysutton
@callowaysutton 2 ай бұрын
@@micheloe he's talking about the TCP slow start algorithm, 10 packets are sent first and doubled until something drops
@rayzecor
@rayzecor 2 ай бұрын
I really appreciated the pride you have for this simple and small demonstration. The ending was also funny
@풍월상신
@풍월상신 3 ай бұрын
'텀' wasn't just a designed logo, it was intended Hangul.. That's lovely. And this video was helpful for me. Thanks 텀.
@sivasankaransomaskanthan8264
@sivasankaransomaskanthan8264 3 ай бұрын
what does that mean ?
@풍월상신
@풍월상신 3 ай бұрын
@@sivasankaransomaskanthan8264 Hangul is korean alphabet and writing system. 'ㅌ' is like 'T' in pronounce, while 'ㅓ' like 'O' and 'ㅁ' is 'M' Altogether, '텀' is 'Tom' in Hangul.
@sivasankaransomaskanthan8264
@sivasankaransomaskanthan8264 3 ай бұрын
@@풍월상신 Thanks for the answer. Now I feel like I have learned to read korean lanuage. that's cool
@elliotwaite
@elliotwaite 3 ай бұрын
@@풍월상신 It also looks like the letters T O M going around clock-wise (but the ㅓ is the T and the ㅌ is the M).
@tomontheinternet
@tomontheinternet 3 ай бұрын
A lucky coincidence!
@appwala3728
@appwala3728 3 ай бұрын
This is great we need more depp knowledge like this. It's a request for you sir.
@pranksterboss139
@pranksterboss139 3 ай бұрын
Definitely didn't know this before watching this video, I just accepted that awaiting JSON is what you had to do. Nice video!
@AurelioPita
@AurelioPita 3 ай бұрын
Very well explained. We need more advanced content like this.
@LearnWebCode
@LearnWebCode 3 ай бұрын
You're an amazing teacher; thanks for the great explanation and focusing on the "why" behind things.
@Pawansoni432
@Pawansoni432 2 ай бұрын
wow! never knew learning streams could be that easy! and today i got the idea on why we await two times for the fetch; first the headers arrives followed by body.
@mukeshnegi9720
@mukeshnegi9720 19 күн бұрын
Really Great Demo and explaination Tom. I have mostly used Axios for my projects but when I started using fetch, this was the very first question in mind that why the hell I have to wait twice to get my json data. Thanks for this!!!
@JonLynchIsAlive
@JonLynchIsAlive 3 ай бұрын
This is actually a great explanation of the need for the second promise. This made me think of the fact that some developers will make a "HEAD" request to see if a resource is available. But it could just be done with that initial response using headers alone.
@jpisello
@jpisello 3 ай бұрын
Using the HEAD request will be more efficient for the server, though, since it won't actually send the body (contents) of the requested URI. (Also, the requester _does_ actually get the content in a GET/POST request-whether your code reads it or not.) So altogether, if you just need to know whether a resource exists, use HEAD.
@JonLynchIsAlive
@JonLynchIsAlive 3 ай бұрын
@@jpisello true!
@callowaysutton
@callowaysutton 2 ай бұрын
Oh that's pretty sweet, so you could get the content length of the body and make a nice little loading bar too, even if everything hasn't been received yet
@quinndirks5653
@quinndirks5653 3 ай бұрын
Great video! I have been doing javascript for awhile, but this is the first time I've seen someone show an example of streaming data in from a fetch request... I didn't even know it was possible. Very cool!
@ariyoujahan9662
@ariyoujahan9662 2 ай бұрын
Wow, it was absolutely amazing. I need to check out your other videos (this was the first one) Hope I'm finally finding some advanced JS KZbin channel.
@imadetheuniverse4fun
@imadetheuniverse4fun 3 ай бұрын
i don't know if the abrupt cutoff in the middle of endorsing your channel was intentional, but it was perfect imo. subbed! :P
@tomontheinternet
@tomontheinternet 3 ай бұрын
Intentional!
@cjbios2080
@cjbios2080 19 сағат бұрын
I do love when a fellow developer loves his work and proud of what he's done, so enjoyable to watch :) This video is so crystal clear, so nicely made Sir !!
@homesynthesis
@homesynthesis 3 ай бұрын
For await feels incredibly cursed but I'm glad I now know about it and can't wait to use it as much as humanly possible
@danielghirasim2544
@danielghirasim2544 3 ай бұрын
Very cool explanation, thank you! I am also getting attacked by killer robots when I code
@tomontheinternet
@tomontheinternet 3 ай бұрын
Glad I’m not alone
@douglasgabriel99
@douglasgabriel99 3 ай бұрын
Already knew that, but the way this video explained was so entertaining! Really great work!
@RusuTraianCristian
@RusuTraianCristian Ай бұрын
The browser and server already do the heavy lifting of streaming and parsing the big piece of data in small chunks, incrementally (thus the 'streaming'). So in the frontend, all you need to do is create a 'for of' loop (because it can 'await' things) and build a string/content with the coming data. I've been doing this for years because I have many circumstances where we had to display things as they come in, rather than waiting for the whole thing to process and then BANG, fill up the screen. It's a nice, informative/educational piece of video nonetheless. Well done!
@jamesdenmark1396
@jamesdenmark1396 2 ай бұрын
20 years of using javascript, first time i know, thank you
@ogyct
@ogyct 2 ай бұрын
Thanks for the video. It's good to see not only how to do things, but also why. With deep understanding and good examples.
@ThisAintMyGithub
@ThisAintMyGithub 3 ай бұрын
Wow, I had no idea and I've been using Node for 5 years. Great video!
@sourav_kd
@sourav_kd 3 ай бұрын
This is the first time I've come across someone explaining this topic! This could also be a great interview question. Thanks a lot. You gained a subscriber here.
@SigSeg-V
@SigSeg-V 2 ай бұрын
0:15 who's Jason?
@dough-pizza
@dough-pizza 2 ай бұрын
BA DUM TSSS
@Nothingjustaninchident123
@Nothingjustaninchident123 Ай бұрын
😂😂😂
@ayoubalfurjani4531
@ayoubalfurjani4531 Ай бұрын
I like the simple explanation and the overall vibes.
@r1konTheAutomator
@r1konTheAutomator 2 ай бұрын
This is my first time finding your channel. I really like listening to you talk lol - but nothing beats the outtro. I almost spit coffee out of my face when it cut off at the very end. I looked away from the screen totally expecting "like, share, subscribe, patreon, etc" and got the "please distract these things, I really need he--" genius 🤣 You got a sub from me just on that.
@ApplyIT2021
@ApplyIT2021 3 ай бұрын
Practical explanation is really amazing...
@dazealex
@dazealex 2 ай бұрын
Nice stuff! Ofcourse, as a Go programmer, I don't deal nor look too deep into JS, this was still useful and nicely illustrated. Give us more!
@paperC_CSGO
@paperC_CSGO 3 ай бұрын
Really like videos like this, going into detail on specific, small things in web development. So many other videos out there are general overview courses, but for us junior devs these type of videos are gold to expand are knowledge
@cherubin7th
@cherubin7th Ай бұрын
Lifting one of the greatest mysteries ever.
@tomaspecl1082
@tomaspecl1082 3 ай бұрын
I dont use javascript but I was using one rust library that has basically the same structure of awaiting twice. I did not understand why it did that, I could only think that they made the decoding asynchronous but that would be so weird. Now I think I know why they did the same thing.
@cjnewbs
@cjnewbs 2 ай бұрын
Only really figured this out a couple months ago when discussing it with a work colleague. (I don’t write much js at all). This is the thing that annoys me most about js tutorials that explain promises. They explain what the await does (or the .then) and then will always give the example using fetch but won’t explain why there’s 2 of them, I’m sat there like “did I miss something?!?” This video should be required watching for learning js. Good job!
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars 3 ай бұрын
simple and to the point, thank you :)
@dennischen2922
@dennischen2922 3 ай бұрын
Your Neovim setup looks gorgeous, could you share your dot files?
@tomontheinternet
@tomontheinternet 3 ай бұрын
github.com/tom-on-the-internet/dotfiles Enjoy!
@exactzero
@exactzero 3 ай бұрын
Simple, to the point but detailed. Subscribed.
@foraminifera7001
@foraminifera7001 3 ай бұрын
What is this theme of your terminal? I really like it) Is this something like OhMyPosh or Neovim theme?
@realderek
@realderek 3 ай бұрын
Great explanation. Seems very obvious now but I wasn’t thinking about the headers and body not coming in at the same time.
@kal9421
@kal9421 2 ай бұрын
what I know is that response.json can return an error if the json is malformated ( same for JSON.parse ) and having it in a promise format help us to think about catching the promise if it fail for some reason anyway I loved this video and I learned a new thing thank you
@eddienubes
@eddienubes 2 ай бұрын
the outro is golden, thank you for the quality vid!
@alibekcs
@alibekcs 2 ай бұрын
Never knew streaming could be that easiy. Amazing video!
@testermobile834
@testermobile834 2 ай бұрын
Tom can you make a video on vocoder theme the terminal ui change you did& also how you edit the videos
@jmg9509
@jmg9509 Ай бұрын
What was that ending?
@pabloenriquegorga4222
@pabloenriquegorga4222 3 ай бұрын
new here, i clicked on the video and i watched till the end. I understood the concept when you showed the documentation, but it was a great surprise to see the last part of the video, the "textDecode" part, and the "for 'await' ",that was awesome. Please do and other video about that part, I wonder what else can that be used for. but the way, new subscriber here too !
@saravanasai2391
@saravanasai2391 Ай бұрын
Hey, that is a great explanation. I understood that the complete response body is waiting to get a transfer, but I was wondering when the response body converted into valid JSON. I know that conversion takes sometime incase of a huge pay load.
@picklypt
@picklypt 3 ай бұрын
I have an unrelated question. I have looked into your dotfiles and cannot find where you set it up so that highlighted text becomes bold ( as seen in 0:30 ). Is that a manual config or part of your colorscheme? Thanks :)
@OneDay_to_DayOne
@OneDay_to_DayOne 6 күн бұрын
thanks for the video, it was informative. what is the background theme you are using for your code editor?
@tomontheinternet
@tomontheinternet 5 күн бұрын
This is Catppuccin Frappe
@MAK_007
@MAK_007 3 ай бұрын
love these type of videos with showcasing practically. thanks for the video. great work
@antoinelb8509
@antoinelb8509 3 ай бұрын
So why there is not second await on axios? (maybe both are combined?)
@JagaSantagostino
@JagaSantagostino 3 ай бұрын
Axios doesn’t use fetch internally, it predates fetch even existing by a few year, it is based on XMLHttpRequest
@Georgggg
@Georgggg 3 ай бұрын
because its better API, than native fetch
@AmitabhSuman
@AmitabhSuman 2 ай бұрын
Supraaawesome! The interface, the code and the excitement with which you explain this. Thank you!
@HarshdeepSaiyam
@HarshdeepSaiyam 2 ай бұрын
The text decoder was soo cool man 😍
@heyiammahadev
@heyiammahadev 3 ай бұрын
Is there a chance that server sends 200 first but something happened while sending body and server error or bad request occurs
@ShortFilmVD
@ShortFilmVD 3 ай бұрын
Yes, that's why it's important to validate the body of the response and not rely on the http status header alone.
@hehimselfishim
@hehimselfishim 2 ай бұрын
@@ShortFilmVD interesting, does this issue happen in axios as well? genuinely curious, never experienced this before.
@ShortFilmVD
@ShortFilmVD 2 ай бұрын
@@hehimselfishim I don't think so, but I'd have to take a look at the code - it's been a while since I've used Axios. The main time this would happen is with a connection drop that doesn't get re-establish in time for TCP (or QUIC nowadays) to finish the transfer properly. These days it's a pretty rare occurrence.
@mike_dev2014
@mike_dev2014 2 ай бұрын
Today I feel more senior developer than Yestarday. well done video
@nicholas_obert
@nicholas_obert 3 ай бұрын
How does JS know when the async for loop is finished? Does it check whether the "body" property is bound to a promise? Or maybe the "body" property is a Promise type and it gets converted into a blob type (or whatever JS type that is) only after it has been awaited so that typeof(response.body) is a promise and typeof(await response.body) is the actual body?
@msc8382
@msc8382 3 ай бұрын
I believe they've implemented something similar to co-routines. This is the event loop in javascript. I suspect that the stack can be frozen and moved away from the event loop. In such a case, the await operation would move the suspended stack from the event loop, and the new promise is added to the end of the queue for promises. The event loop also takes promises from this queue if the event loop queue itself is empty. This means there are two levels of event handling; client events, timeouts, main javascript and promises. Eventually, the event loop processes the new promise, which promptly has an association to the earlier stack due the await operation. That's how the promise would cause the stack to be recovered and unfrozen, now with the result available. In normal co-routine implementations, you would have multiple threads where one main thread manages the order and locking of the operational threads. In an earlier version of Unity game engine for example, the co-routine implementation was used because then you could interact with the game engine from the main thread, which was the only real way to use it at the time. Real parallelisation can be hard, if you don't know about CAS operations. I've never personally understood why javascript implementations aren't multi-threaded. But I'm fairly happy with their async implementations. Could be worse. Perhaps this was not an answer you were looking for, but I think it should help you answer your own. for loops or not, promises are promises. Handled the same no matter what operation it represents. I can imagine that they've added more types of data to the promises hidden in the engine, such as iterator information. As long as they'd use a single thread or CAS operations, its fairly safe to find the next key that wasn't processed yet. I've personally programmed in C++11 where this was firstly released. I also use async a lot in javascript. PS: I create a lot of async arrow functions that use the bounded scope of the underlaying function to compute and hold information for a duration until an operation completes. The underlaying function does complete, and release that part of the stack. The scope itself is preserved due to the capture mechanics around variable functions. I find it an easy way to return signal registers or execute an async operation inline that way while having big or long call stacks be released. The benefit of it is that you get the full call stack trace still during errors, because it detects the connection due the capturing, but the actual underlaying stack has been released. I've never had performance issues on my web interfaces using this technique, and no corruption of data over time either. This was probably a bit vague and sorry for that. I've never seen anybody use async operations in the way I do them. To be exact: I do it so that all async operations complete as soon as possible, and by returning the underlaying function immediately, the event loop resumes the main events first. This ensures a reactive user interface regardless of what happens on the async queue. In my practical experience, it often means that input processing is delayed, but all html input and css stays fully reactive. That's how I want my interfaces to be. Cheers
@thomasle100
@thomasle100 3 ай бұрын
hello ! You can check my other response. I guess that the async for loop it's just sugar syntax on top of reader. You can get the "reader" by calling the method getReder on response. On reader, you have a method read, that returns a promise object. The object contains 2 properties : "done" which is a boolean, and a data chunk. So you have to call continuously the method read until the property done is true. So now imagine you create an async generator, you await the result of the read and then you yield each chunk of data. You'll get an async iterator that you can use with the for await loop syntax. I think it's what is done in the source code but I didn't check.
@nicholas_obert
@nicholas_obert 3 ай бұрын
Makes sense
@MichaelChanCY
@MichaelChanCY 3 ай бұрын
Wow! Your demonstration is perfect! Great work!
@AnasImloul
@AnasImloul Ай бұрын
In HTTP, we have a Content-Length header that indicates the number of bytes in the response body. Given that the await in the first fetch operation retrieves only the headers, does this imply that the Content-Length header cannot be set correctly before the entire body is streamed?
@AnasImloul
@AnasImloul Ай бұрын
Shouldn't the Content-Length header be specified by the server before it begins streaming the response? In your use case, you used res.end() to signal the end of the response body, which means that until res.end() is called, there’s no way to determine the Content-Length value.
@nimitsavant3127
@nimitsavant3127 3 ай бұрын
amazing video 🥑 What are you using to record this?
@TENNISMANIAC144
@TENNISMANIAC144 3 ай бұрын
Thank you! Fwiw, I bailed on the video early because as soon as you explained it high level I completely got it, but commenting to hopefully balance out not watching the whole video's impact on performance.
@hackytech7494
@hackytech7494 3 ай бұрын
Thank you very much this video, learned a lot, I was constantly being disturbed by the thought that why do I have to do the await two time, but now I know. Thanks to you
@radvilardian740
@radvilardian740 2 ай бұрын
Hello, I comeback for the closing scene only, still not forgeting the "give me 1000 dollars" tho.
@antonpieper
@antonpieper 3 ай бұрын
I didn't know xou could create a textdecoder and read the stream, very cool. I would have probably used SSE before this video
@95sita
@95sita 2 ай бұрын
Very educative. By the way, which IDE are you using in this video? Thanks in advance.
@tomontheinternet
@tomontheinternet 2 ай бұрын
Neovim!
@hacktor_92
@hacktor_92 3 ай бұрын
so... to my understainding, `response.json` waits for server's data stream to finish up before doing the actual decode. Now I'm wondering if we can stream JSON content and progressively decode it (and render it in DOM) while incoming. I'm thinking for it from the perspective of huge data tables.
@filipesommer8253
@filipesommer8253 3 ай бұрын
Very interesting. I wonder if they're would be a way to only need one await if we knew the response was a non-streaming request?
@mkrzyzowski
@mkrzyzowski Ай бұрын
This is first explanation which make me understand that. Thank you!
@andreidmt-asd
@andreidmt-asd 2 ай бұрын
Nailed the background music.
@dvdrtrgn
@dvdrtrgn 2 ай бұрын
Background music is as pointless as a disco ball in this context
@jamashe
@jamashe 3 ай бұрын
Could you share you neovim config? It looks pretty nice. And thanks.
@danielgilleland8611
@danielgilleland8611 3 ай бұрын
... which begs the question, what if all you want is the Header information? Can you then send a cancellation token after getting the response so that the server can dispense with continuing its response of the body?
@andrewcraig8177
@andrewcraig8177 3 ай бұрын
Use the HEAD method instead of GET
@victorlongon
@victorlongon Ай бұрын
Such a nice video. Very beautiful style and clear explanation! ❤
@teraformerr
@teraformerr 3 ай бұрын
very good and informative video, asked myself this week why we need to await 2 times
@gabrielruffo6439
@gabrielruffo6439 Ай бұрын
What happens if the server returning the body goes down while providing the response body byte by byte?
@hi12167pies
@hi12167pies 3 ай бұрын
awesome vid! i always wondered this but never bothered to actually find out why.
@ericisawesome476
@ericisawesome476 2 ай бұрын
I was just wondering about this the other day, great video
@N_N_N
@N_N_N 3 ай бұрын
Short and to the point, great video.
@VikasKumar-j2s4v
@VikasKumar-j2s4v 3 ай бұрын
what editor is this?
@inupete69
@inupete69 2 ай бұрын
the cutoff at the end
@hitdong
@hitdong 3 ай бұрын
waaaait a second! it's 텀! wow. I'm surprised as a Korean. I thought I saw illusion, so I had to rewind and play it again. LOL nice to meet you 텀
@hellotherenameishere
@hellotherenameishere 3 ай бұрын
Haha that ending is so self-aware, easy sub 👍
@KaiserSakhi-1
@KaiserSakhi-1 3 ай бұрын
Great video! Which font are you using?
@tomontheinternet
@tomontheinternet 3 ай бұрын
IBM plex mono
@KaiserSakhi-1
@KaiserSakhi-1 2 ай бұрын
@@tomontheinternet Thanks!
@glebbash
@glebbash 3 ай бұрын
What do you use for recording? Quite cool that you can drag the webcam window during recording.
@tomontheinternet
@tomontheinternet 3 ай бұрын
I’m using Cleanshot X on Mac. It’s a great program.
@0xc0ffee_
@0xc0ffee_ 2 ай бұрын
Very interested in your nvim configuration. It looks very clean :) Working on remodelling mine
@itayperry8852
@itayperry8852 2 ай бұрын
Cool!! Very interesting to see that! I loved the ending with the decoder ♥️ Thank you :)
@yosvelquintero
@yosvelquintero 3 ай бұрын
You can create a reusable method that handles the fetching and JSON parsing in one line. Here’s an example: ``` const fetchJson = async (url) => (await fetch(url)).json(); ``` Then: ``` const result = await fetchJson('/api/endpoint/json'); ```
@Joshua-dc4un
@Joshua-dc4un 3 ай бұрын
Because it takes time to decode the response or should I say encode into your desired format
@rabbyhossain6150
@rabbyhossain6150 2 ай бұрын
that's cool. I used "fetch" many times but I thought first promise actually fetched everything. Now I know it's just the header content.
@Dopamine432
@Dopamine432 3 ай бұрын
what terminal are you using. it looks super cool
@iulikdev
@iulikdev 3 ай бұрын
You explained very well. Nice. Long time ago i had hard time to understand this.
@arsinclair
@arsinclair 2 ай бұрын
The ending is Oscar-like
@anirudhpundir8588
@anirudhpundir8588 2 ай бұрын
can we replace pagination with this, at least for tables where most of data is in text form??
@tomontheinternet
@tomontheinternet 2 ай бұрын
Generally no, you can’t. Pagination requires the client to ask for the next page. You could slowly load more data in the background, personally I’d avoid that route
@zionlee1004
@zionlee1004 3 ай бұрын
what does the 텀 mean in the lower right side of your editor(vim?)...?
@yuvaleliav3709
@yuvaleliav3709 2 ай бұрын
normal youtubers: please subscribe this random guy: can you please distract the killer robots in this random picture while I finish my sente
Create a Financial Calculator in Rust
45:36
Torbjorn Storli
Рет қаралды 108
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
The Dark Matter of AI [Mechanistic Interpretability]
24:09
Welch Labs
Рет қаралды 71 М.
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
12:35
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 701 М.
The Every UUID Website Explained
33:43
ThePrimeTime
Рет қаралды 241 М.
The intro to Docker I wish I had when I started
18:27
typecraft
Рет қаралды 334 М.
I'm Ditching Try/Catch for Good!
10:29
Web Dev Simplified
Рет қаралды 190 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
The 3 Laws of Writing Readable Code
5:28
Kantan Coding
Рет қаралды 789 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН