The "fetch api" can also convert base64 image to blob, which you can send later to some API as form-data. I had to do this recently and was quite amazed by it.
@winter-survivor3 жыл бұрын
This guy voice's tone is like he were telling a horror story 🎃🤣. Great content 👍
@Tiddle_s3 жыл бұрын
He is talking about JavaScript so...
@astropgn3 жыл бұрын
sounds like a true crime podcast
@SquaredbyX3 жыл бұрын
That's because he's baron Nasser...
@rahulbalan3 жыл бұрын
There's never too much of Nasser Hussein. You're awesome.
@reitznerdomenik3 жыл бұрын
Headers: technically multiple headers with the same name can exist. If you have a JSON structure, than you might kill duplicate headers 😉
@cssssp21923 жыл бұрын
Thanks for the information, sir.
@ashiqsultanmohamed97653 жыл бұрын
All my homies use Axios
@sadhlife3 жыл бұрын
fetch better, fite me
@divyanshusah28093 жыл бұрын
No
@IAmLesleh3 жыл бұрын
Axios is pretty much dead now, just fyi.
@flavioneto10813 жыл бұрын
@@IAmLesleh there are currently 17.479.853 weekly downloads on npm, why you say?
@raahimfareed3 жыл бұрын
@@flavioneto1081 you don't need node or npm for fetch though, and axios was last updated 8 months ago
@gavdev123 жыл бұрын
I really like videos like this that just dive into interesting features of commonly used patterns that most people don’t think twice about
@smoothbeak3 жыл бұрын
I love that there is a guy who loves fetch haha
@samuraitatin3 жыл бұрын
Your voice and the way you narrated this video made me want to use the fetch API right away. Thank you!
@tikz.-37383 жыл бұрын
The read() is basically a async generator function u can do for await(const value of res.read()){ console.log(value) } And it will read all values overtime basically to loop through values as they are parsed instead of waiting for all of it to be parsed
@noahwilliams89183 жыл бұрын
Classic Hussein video, shows an appreciation of something that was totally off my radar, and in so doing, explains it beautifully :)
@ThinkSoftware3 жыл бұрын
The single word that Hussein use most often -> Beautiful
@stevenalexander62623 жыл бұрын
Right after I read this, I heard him say it 🤣
@ndie93663 жыл бұрын
If only it had a way to watch progress when uploading files.
@danielzaiser3 жыл бұрын
retrying this only leads to errors in the dev tool console :(
@snacksy77543 жыл бұрын
I don't know if actually enjoys the fetch API or is just being extremely sarcastic throughout the entire video.
@dealloc3 жыл бұрын
The Fetch API supports more than just HTTP and HTTPS schemes, it also supports file, blob and data schemes. These are useful for converting a string of data (data), a blob or a local file from your file system into a stream and further parsed as JSON, Text, ArrayBuffer, Blob or FormData.
@javilionaire3 жыл бұрын
Great video. I agree completely. Thanks for posting!
@parasite67313 жыл бұрын
Dude how you finished 12 min video within 1 minute 😂
@questreal58123 жыл бұрын
@@parasite6731 that's the trust he has in Hussein
@randomrandom3163 жыл бұрын
It would have been nice if you had showcased an example situation where this would have been beneficial. From what I can see for json data this is most certainly of no good use in most general cases.
@ash-faque3 жыл бұрын
reading a blog post, if its too large, parse it as small chunks as the user reads more and more, rather than parsing altogether
@jimshtepa54233 жыл бұрын
thank you for the video. How would you read/parse incoming uint8array in firefox where textdecoder is not supported?
@The-Dev-Ninja3 жыл бұрын
does it also work on chrome?
@divyanshusah28093 жыл бұрын
Lmao 🤣🤣
@seanthesheep3 жыл бұрын
Since let is a statement, it doesn't return anything. Since the console isn't in strict mode, you can just not declare the variables, and the assignment operator will return the stored value
@greysonsawyer3 жыл бұрын
I love this video! Such a kind and exciting way of teaching
@KarahannAe3 жыл бұрын
If I make a fetch request to a public api from my client side rendered app, who does the request count for? The user or the server that served the client side app? I am asking for rate limiting purposes.
@cryptus_neoxys3 жыл бұрын
The user
@ruhan233 жыл бұрын
Love your content form Kashmir tell me why do some browsers allow the fetching, while others dont (cors)??
@andrewmartin36713 жыл бұрын
A close analogue of streamable JSON is one JSON object per line in a file. Super easy to parse.
@sadhlife3 жыл бұрын
yup, it's usually called JSONL
@robotduck773 жыл бұрын
it doesn't work on IE6
@remrevo39443 жыл бұрын
Actually there is a way to get json streamable. In some cases you don't get a full json object from an api, but one json object per line, I often use a command line tool named jq to process json, which can process big json files using a streamable mode.
@rakeshsarangi51613 жыл бұрын
TIL
@soniablanche56723 жыл бұрын
sadly most people use Axios, which uses XHR and not fetch. fetch has one problem that still hasn't been fixed: It's incapable of telling you how much data it's uploading at a time, so you can't create an upload progress bar with fetch.
@erikslorenz3 жыл бұрын
I like fetch because I always have to write my own damn wrapper around even if I'm using axios. I used to use it exclusively but then there's some random thing I want to change and I'm like ugh. I wish I just had a good wrapper function I could add to the basic.
@dasten1233 жыл бұрын
That's neat! I didn't know you could stream the raw content. But what you showed is all happening after everything was downloaded, right?
@optimiserlenergie10943 жыл бұрын
That is a good question, I got the same understanding
@hirisraharjo3 жыл бұрын
Probably yes, but parsing the downloaded data is a whole new activity
@dasten1233 жыл бұрын
Nope, I found out the chunks are actually coming in while the browser is downloading the content. You can test it by fetching a really large file. The fetch() resolves when the connection is established, _not_ when everything is downloaded like I originally thought. Now It makes sense to me why response.json() is a promise, because that needs to wait until everything is loaded.
@mpcabete3 жыл бұрын
Thanks, I definitely will use this in the future.
@darwinmanalo54363 жыл бұрын
Love your content Hussein. Do you use graphql?
@hodev6323 жыл бұрын
with axios you can do interception . Like auto request on refresh token Or get access token automaticaly Or you can auto response .
@minma022623 жыл бұрын
There are a lot of "gotchas" with fetch() compared to a typical ajax library. You need to get used to it before it is familiar enough to be productive. It was extremely annoying to use fetch in the beginning, now I am familiar with the differences. I just use a simple wrapper around fetch() to make processing easier.
@JinKee3 жыл бұрын
Are we still trying to make Fetch a Thing?
@igorswies59133 жыл бұрын
wdym
@Palundrium3 жыл бұрын
"Those guys don't do anything without a reason" 😂 Also, made me think... Probably because they realized whatever they do is never going away (at least until the web does).
@ruhnet3 жыл бұрын
Looks like the JS devs have started looking at how it's done with Golang :-) Great stuff and fantastic video as always!
@tgiflying3 жыл бұрын
Array of arrays is valid JSON!
@shivankriyalalexis43763 жыл бұрын
Great vedeo bro love from india
@sayonarasun15773 жыл бұрын
great as always. thanks Hussein
@grahamjoss46433 жыл бұрын
You quibble with the ideas in a similar tone to sal Kahn
@disgracefulsense78823 жыл бұрын
native standart things always work better
@aamiralam52013 жыл бұрын
Is it good practice to use fetch directly instead of axios. because axios does much more work for us instead of just fetching the data
@s7s_space3 жыл бұрын
quite boring ! I didn't get the final idea in End what I can get the v value to be Json to read ? we can make a kind of loading waiting or paging ..etc !
@oluwatomisinbabatunde84263 жыл бұрын
It’ll be relevant based on purpose and I see this being cool in NodeJs
@dealloc3 жыл бұрын
All the data is still fetched as bytes in a ReadableStream but not parsed until the body is extracted with json, text, blob, arrayBuffer or formData methods. Those are async, which, yes, you can _wait_ on (show a loading spinner) as part of the lifecycle of your app. This isn't used for pagination. Pagination still has to be done by the server.
@niloysikdar67483 жыл бұрын
Axios is crying in a corner :)
@George-rr1cd3 жыл бұрын
Great video as always 👍👍.
@SamriBliss3 жыл бұрын
I’m working on building my own API and use fetch
@friendlybear59243 жыл бұрын
Great video.
@SirXtC3 жыл бұрын
4:48 wth lol
@rajashekhar4333 жыл бұрын
How to get good knowledge in nodejs?
@ashiqsultanmohamed97653 жыл бұрын
Do small projects
@dasten1233 жыл бұрын
Do big projects
@nickschmitt85943 жыл бұрын
unix mode activated
@jamdonut3 жыл бұрын
wait until this man discovers cURL xD. jk fetch is much nicer than xmlxrp
@oumardicko55933 жыл бұрын
That was some good stuff
@fnzip3 жыл бұрын
Your voice not same with ordinary "indian" yotuber haha, btw nice content
@andrewcathcart3 жыл бұрын
Not really ideal to do Array.from() on the headers as they're already a map.
@blazi_03 жыл бұрын
yea men its awsome !
@dannymendiola3 жыл бұрын
where are the mean girls jokes
@entrey_ua3 жыл бұрын
cool. like it.
@davidmcken3 жыл бұрын
Looks allot like the requests library for python.
@WrittenInFilm3 жыл бұрын
no offense dude but fetch is no where near an innovation of any kind
@dasten1233 жыл бұрын
I'm guessing you wasn't around when it wasn't available
@WrittenInFilm3 жыл бұрын
@@dasten123 ive been around for a very long time, and ive written network drivers, this functionality is literally inherent on low level code that just passes the pointer to the payload buffer up to the higher level javascript language, its literally so unrevolutionary that you have to write extra code for the payload to not be accessed by dereferencing the pointer..
@vitiok783 жыл бұрын
Still using axios)))
@wduandy3 жыл бұрын
Nahh axios >>>
@justafreak15able3 жыл бұрын
Popular opinion: Working with fetch is time-consuming. It should be only used in the console.
@gabrieltron42403 жыл бұрын
Care to elaborate? I'm not used to develop with javascript, got curious.
@justafreak15able3 жыл бұрын
@@gabrieltron4240 Use axios if you want a http client.
@JustValxntine3 жыл бұрын
@@justafreak15able that's not elaborating at all. Why use Axios over Fetch
@justafreak15able3 жыл бұрын
@@JustValxntine wasn't gonna. Please use Google.
@JustValxntine3 жыл бұрын
@@justafreak15able another way of saying "I have no idea". Nice