fetch is beautiful

  Рет қаралды 55,551

Hussein Nasser

Hussein Nasser

Күн бұрын

Пікірлер: 122
@pemessh
@pemessh 3 жыл бұрын
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-survivor
@winter-survivor 3 жыл бұрын
This guy voice's tone is like he were telling a horror story 🎃🤣. Great content 👍
@Tiddle_s
@Tiddle_s 3 жыл бұрын
He is talking about JavaScript so...
@astropgn
@astropgn 3 жыл бұрын
sounds like a true crime podcast
@SquaredbyX
@SquaredbyX 3 жыл бұрын
That's because he's baron Nasser...
@rahulbalan
@rahulbalan 3 жыл бұрын
There's never too much of Nasser Hussein. You're awesome.
@reitznerdomenik
@reitznerdomenik 3 жыл бұрын
Headers: technically multiple headers with the same name can exist. If you have a JSON structure, than you might kill duplicate headers 😉
@cssssp2192
@cssssp2192 3 жыл бұрын
Thanks for the information, sir.
@ashiqsultanmohamed9765
@ashiqsultanmohamed9765 3 жыл бұрын
All my homies use Axios
@sadhlife
@sadhlife 3 жыл бұрын
fetch better, fite me
@divyanshusah2809
@divyanshusah2809 3 жыл бұрын
No
@IAmLesleh
@IAmLesleh 3 жыл бұрын
Axios is pretty much dead now, just fyi.
@flavioneto1081
@flavioneto1081 3 жыл бұрын
@@IAmLesleh there are currently 17.479.853 weekly downloads on npm, why you say?
@raahimfareed
@raahimfareed 3 жыл бұрын
@@flavioneto1081 you don't need node or npm for fetch though, and axios was last updated 8 months ago
@gavdev12
@gavdev12 3 жыл бұрын
I really like videos like this that just dive into interesting features of commonly used patterns that most people don’t think twice about
@smoothbeak
@smoothbeak 3 жыл бұрын
I love that there is a guy who loves fetch haha
@samuraitatin
@samuraitatin 3 жыл бұрын
Your voice and the way you narrated this video made me want to use the fetch API right away. Thank you!
@tikz.-3738
@tikz.-3738 3 жыл бұрын
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
@noahwilliams8918
@noahwilliams8918 3 жыл бұрын
Classic Hussein video, shows an appreciation of something that was totally off my radar, and in so doing, explains it beautifully :)
@ThinkSoftware
@ThinkSoftware 3 жыл бұрын
The single word that Hussein use most often -> Beautiful
@stevenalexander6262
@stevenalexander6262 3 жыл бұрын
Right after I read this, I heard him say it 🤣
@ndie9366
@ndie9366 3 жыл бұрын
If only it had a way to watch progress when uploading files.
@danielzaiser
@danielzaiser 3 жыл бұрын
retrying this only leads to errors in the dev tool console :(
@snacksy7754
@snacksy7754 3 жыл бұрын
I don't know if actually enjoys the fetch API or is just being extremely sarcastic throughout the entire video.
@dealloc
@dealloc 3 жыл бұрын
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.
@javilionaire
@javilionaire 3 жыл бұрын
Great video. I agree completely. Thanks for posting!
@parasite6731
@parasite6731 3 жыл бұрын
Dude how you finished 12 min video within 1 minute 😂
@questreal5812
@questreal5812 3 жыл бұрын
@@parasite6731 that's the trust he has in Hussein
@randomrandom316
@randomrandom316 3 жыл бұрын
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-faque
@ash-faque 3 жыл бұрын
reading a blog post, if its too large, parse it as small chunks as the user reads more and more, rather than parsing altogether
@jimshtepa5423
@jimshtepa5423 3 жыл бұрын
thank you for the video. How would you read/parse incoming uint8array in firefox where textdecoder is not supported?
@The-Dev-Ninja
@The-Dev-Ninja 3 жыл бұрын
does it also work on chrome?
@divyanshusah2809
@divyanshusah2809 3 жыл бұрын
Lmao 🤣🤣
@seanthesheep
@seanthesheep 3 жыл бұрын
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
@greysonsawyer
@greysonsawyer 3 жыл бұрын
I love this video! Such a kind and exciting way of teaching
@KarahannAe
@KarahannAe 3 жыл бұрын
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_neoxys
@cryptus_neoxys 3 жыл бұрын
The user
@ruhan23
@ruhan23 3 жыл бұрын
Love your content form Kashmir tell me why do some browsers allow the fetching, while others dont (cors)??
@andrewmartin3671
@andrewmartin3671 3 жыл бұрын
A close analogue of streamable JSON is one JSON object per line in a file. Super easy to parse.
@sadhlife
@sadhlife 3 жыл бұрын
yup, it's usually called JSONL
@robotduck77
@robotduck77 3 жыл бұрын
it doesn't work on IE6
@remrevo3944
@remrevo3944 3 жыл бұрын
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.
@rakeshsarangi5161
@rakeshsarangi5161 3 жыл бұрын
TIL
@soniablanche5672
@soniablanche5672 3 жыл бұрын
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.
@erikslorenz
@erikslorenz 3 жыл бұрын
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.
@dasten123
@dasten123 3 жыл бұрын
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?
@optimiserlenergie1094
@optimiserlenergie1094 3 жыл бұрын
That is a good question, I got the same understanding
@hirisraharjo
@hirisraharjo 3 жыл бұрын
Probably yes, but parsing the downloaded data is a whole new activity
@dasten123
@dasten123 3 жыл бұрын
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.
@mpcabete
@mpcabete 3 жыл бұрын
Thanks, I definitely will use this in the future.
@darwinmanalo5436
@darwinmanalo5436 3 жыл бұрын
Love your content Hussein. Do you use graphql?
@hodev632
@hodev632 3 жыл бұрын
with axios you can do interception . Like auto request on refresh token Or get access token automaticaly Or you can auto response .
@minma02262
@minma02262 3 жыл бұрын
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.
@JinKee
@JinKee 3 жыл бұрын
Are we still trying to make Fetch a Thing?
@igorswies5913
@igorswies5913 3 жыл бұрын
wdym
@Palundrium
@Palundrium 3 жыл бұрын
"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).
@ruhnet
@ruhnet 3 жыл бұрын
Looks like the JS devs have started looking at how it's done with Golang :-) Great stuff and fantastic video as always!
@tgiflying
@tgiflying 3 жыл бұрын
Array of arrays is valid JSON!
@shivankriyalalexis4376
@shivankriyalalexis4376 3 жыл бұрын
Great vedeo bro love from india
@sayonarasun1577
@sayonarasun1577 3 жыл бұрын
great as always. thanks Hussein
@grahamjoss4643
@grahamjoss4643 3 жыл бұрын
You quibble with the ideas in a similar tone to sal Kahn
@disgracefulsense7882
@disgracefulsense7882 3 жыл бұрын
native standart things always work better
@aamiralam5201
@aamiralam5201 3 жыл бұрын
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_space
@s7s_space 3 жыл бұрын
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 !
@oluwatomisinbabatunde8426
@oluwatomisinbabatunde8426 3 жыл бұрын
It’ll be relevant based on purpose and I see this being cool in NodeJs
@dealloc
@dealloc 3 жыл бұрын
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.
@niloysikdar6748
@niloysikdar6748 3 жыл бұрын
Axios is crying in a corner :)
@George-rr1cd
@George-rr1cd 3 жыл бұрын
Great video as always 👍👍.
@SamriBliss
@SamriBliss 3 жыл бұрын
I’m working on building my own API and use fetch
@friendlybear5924
@friendlybear5924 3 жыл бұрын
Great video.
@SirXtC
@SirXtC 3 жыл бұрын
4:48 wth lol
@rajashekhar433
@rajashekhar433 3 жыл бұрын
How to get good knowledge in nodejs?
@ashiqsultanmohamed9765
@ashiqsultanmohamed9765 3 жыл бұрын
Do small projects
@dasten123
@dasten123 3 жыл бұрын
Do big projects
@nickschmitt8594
@nickschmitt8594 3 жыл бұрын
unix mode activated
@jamdonut
@jamdonut 3 жыл бұрын
wait until this man discovers cURL xD. jk fetch is much nicer than xmlxrp
@oumardicko5593
@oumardicko5593 3 жыл бұрын
That was some good stuff
@fnzip
@fnzip 3 жыл бұрын
Your voice not same with ordinary "indian" yotuber haha, btw nice content
@andrewcathcart
@andrewcathcart 3 жыл бұрын
Not really ideal to do Array.from() on the headers as they're already a map.
@blazi_0
@blazi_0 3 жыл бұрын
yea men its awsome !
@dannymendiola
@dannymendiola 3 жыл бұрын
where are the mean girls jokes
@entrey_ua
@entrey_ua 3 жыл бұрын
cool. like it.
@davidmcken
@davidmcken 3 жыл бұрын
Looks allot like the requests library for python.
@WrittenInFilm
@WrittenInFilm 3 жыл бұрын
no offense dude but fetch is no where near an innovation of any kind
@dasten123
@dasten123 3 жыл бұрын
I'm guessing you wasn't around when it wasn't available
@WrittenInFilm
@WrittenInFilm 3 жыл бұрын
@@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..
@vitiok78
@vitiok78 3 жыл бұрын
Still using axios)))
@wduandy
@wduandy 3 жыл бұрын
Nahh axios >>>
@justafreak15able
@justafreak15able 3 жыл бұрын
Popular opinion: Working with fetch is time-consuming. It should be only used in the console.
@gabrieltron4240
@gabrieltron4240 3 жыл бұрын
Care to elaborate? I'm not used to develop with javascript, got curious.
@justafreak15able
@justafreak15able 3 жыл бұрын
@@gabrieltron4240 Use axios if you want a http client.
@JustValxntine
@JustValxntine 3 жыл бұрын
@@justafreak15able that's not elaborating at all. Why use Axios over Fetch
@justafreak15able
@justafreak15able 3 жыл бұрын
@@JustValxntine wasn't gonna. Please use Google.
@JustValxntine
@JustValxntine 3 жыл бұрын
@@justafreak15able another way of saying "I have no idea". Nice
@r735g3
@r735g3 3 жыл бұрын
No way they invented Python
First port your computer hits
11:40
Hussein Nasser
Рет қаралды 20 М.
Deep Dive into Blobs, Files, and ArrayBuffers
17:42
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 39 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Postgres just got even faster
26:42
Hussein Nasser
Рет қаралды 38 М.
Streaming requests with fetch - HTTP 203
22:24
Chrome for Developers
Рет қаралды 37 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 445 М.
Astro Crash Course in 20 Minutes!
22:07
Coding in Public
Рет қаралды 62 М.
Learn JavaScript Generators In 12 Minutes
12:11
Web Dev Simplified
Рет қаралды 181 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 224 М.
Where http2 hits its limit
13:13
Hussein Nasser
Рет қаралды 9 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН