The Fetch API has officially made its way into Node.js giving web developers a better default tool for making HTTP requests. Learn why this feature is a big deal and with it means for NPM packages like Axios. 

#firstlook #nodejs #TheCodeReport

🔗 Resources

Node Announcement https://twitter.com/targos89/status/1488471755194867715
Undici Node Fetch https://github.com/nodejs/undici
Fetch Standard https://fetch.spec.whatwg.org/

🔥 Get More Content - Upgrade to PRO

Upgrade to Fireship PRO at https://fireship.io/pro
Use code lORhwXd2 for 25% off your first payment. 

🎨 My Editor Settings

- Atom One Dark 
- vscode-icons
- Fira Code Font

🔖 Topics Covered

- What is the fetch API?
- Why is node fetch a big deal?
- The future of Node.js
- New JavaScript features
- Node fetch vs Axios
2024-02-04T13:43:21.241Z
nova-2
2-general-nova
2024-01-09.29447
30089e05-99d1-4376-b32e-c263170674af
5012269d-d0f4-4f92-95af-df076582871a
a2fe22b4745aed168b2368cd97d00d2b45776eb6b4c480d912e20531d90b3304
67875a7f-c9c4-48a0-aa55-5bdb8a91c34a
deprecated
It is February 4, 2022, and you're watching the Code Report, news you can use.
JavaScript developers are famous for their ability to reinvent the wheel.
In Node.
Js, for example, there are many ways to work with the hypertext transfer protocol.
If you hate yourself, you might use its built in HTTP module, tool, but there is a smorgasbord of third party packages like Axios, NodeFetch, Got, Request, Super Agent, and hundreds of others.
They're extremely popular and account for tens of millions of weekly downloads.
Just this week, developers got some surprise news with a pull request adding support for the fetch API native to play in Node.
Js, just a mere 6 years or so after it became an industry standard via WhatDoubleUG.
Stop trying to make fetch happen.
It's not going to happen.
Fetch is not perfect, but it has proven itself to be good enough to where we don't need to wrap it with a 1,000,000,000 other packages just to avoid mental health issues.
But why is this a big deal?
Well, fetch provides a generic definition of request and response objects and allows you to manage them with to pull promise based API.
Because fetch and node is pretty much identical to the browser, developers have less mental overhead when translating between front end and back end code.
Sharing and common APIs also makes it much easier to develop packages that work both in Node and the browser.
It's something that other runtimes like Deno and Cloudflare workers have already implemented.
So they deserve some credit for giving Node some friendly competition.
Fetch sounds cool, so how do I use it?
As of today, it's not in a public release, but you could build Node from source if you're really motivated.
Keep your eyes peeled for Node version 17.5, where it should be available under an experimental flag, to then expect it to be a standard issue weapon by Node 18.
The implementation is based on a package you can use today called undici, which is named after the character to leaven in Stranger Things.
We can install it in a Node project then import fetch.
It makes scripting in Node really nice because to make a git request, All we have to do is await fetch to access data from any website or API.
And, we don't even need an async function because node also supports top level await.
Now, to make a post request, we can use the same function and modify some of its options like the method, body, and headers.
That's pretty nice, but one question on a lot of people's minds is what does this mean for axios?
Deos.
In my opinion, I think there will still be a place for third party libraries, but the vast majority of projects will be able to get by with what's built into Node, instead of reaching to install to a third party package for every project.
Speaking of things that are dead, in other news, I'm sad to report that our Twitter bot, Bob, has been terminated.
It's my fault because I didn't realize that building Twitter bots with OpenAI is not allowed.
I feel terrible about this, but I really don't wanna lose my API key because I have a lot of their cool ideas for OpenAI.
Bob had a short but impactful life, and apparently, he meant a lot of different things to a lot of different people.
His final words before I pulled the plug were I'll be back.
I don't wanna end this video on a sad note, so in other more uplifting news, Facebook or Meta was down 25% yesterday, and Zuckerberg's net worth declined by about $30,000,000,000 This has been the Code Report.
Thanks for watching, and I will see you in the next one.

Speaker 0: It is February 4, 2022, and you're watching the Code Report, news you can use. JavaScript developers are famous for their ability to reinvent the wheel. In Node. Js, for example, there are many ways to work with the hypertext transfer protocol. If you hate yourself, you might use its built in HTTP module, tool, but there is a smorgasbord of third party packages like Axios, NodeFetch, Got, Request, Super Agent, and hundreds of others.

They're extremely popular and account for tens of millions of weekly downloads. Just this week, developers got some surprise news with a pull request adding support for the fetch API native to play in Node. Js, just a mere 6 years or so after it became an industry standard via WhatDoubleUG. Stop trying to make fetch happen. It's not going to happen.

Fetch is not perfect, but it has proven itself to be good enough to where we don't need to wrap it with a 1,000,000,000 other packages just to avoid mental health issues. But why is this a big deal? Well, fetch provides a generic definition of request and response objects and allows you to manage them with to pull promise based API. Because fetch and node is pretty much identical to the browser, developers have less mental overhead when translating between front end and back end code. Sharing and common APIs also makes it much easier to develop packages that work both in Node and the browser.

It's something that other runtimes like Deno and Cloudflare workers have already implemented. So they deserve some credit for giving Node some friendly competition. Fetch sounds cool, so how do I use it? As of today, it's not in a public release, but you could build Node from source if you're really motivated. Keep your eyes peeled for Node version 17.5, where it should be available under an experimental flag, to then expect it to be a standard issue weapon by Node 18.

The implementation is based on a package you can use today called undici, which is named after the character to leaven in Stranger Things. We can install it in a Node project then import fetch. It makes scripting in Node really nice because to make a git request, All we have to do is await fetch to access data from any website or API. And, we don't even need an async function because node also supports top level await. Now, to make a post request, we can use the same function and modify some of its options like the method, body, and headers.

That's pretty nice, but one question on a lot of people's minds is what does this mean for axios? Deos. In my opinion, I think there will still be a place for third party libraries, but the vast majority of projects will be able to get by with what's built into Node, instead of reaching to install to a third party package for every project. Speaking of things that are dead, in other news, I'm sad to report that our Twitter bot, Bob, has been terminated. It's my fault because I didn't realize that building Twitter bots with OpenAI is not allowed.

I feel terrible about this, but I really don't wanna lose my API key because I have a lot of their cool ideas for OpenAI. Bob had a short but impactful life, and apparently, he meant a lot of different things to a lot of different people. His final words before I pulled the plug were I'll be back. I don't wanna end this video on a sad note, so in other more uplifting news, Facebook or Meta was down 25% yesterday, and Zuckerberg's net worth declined by about $30,000,000,000 This has been the Code Report. Thanks for watching, and I will see you in the next one.
It is February 4, 2022, and you're watching the Code Report, news you can use. JavaScript developers are famous for their ability to reinvent the wheel.
In Node. Js, for example, there are many ways to work with the hypertext transfer protocol. If you hate yourself, you might use its built in HTTP module, tool, but there is a smorgasbord of third party packages like Axios, NodeFetch, Got, Request, Super Agent, and hundreds of others. They're extremely popular and account for tens of millions of weekly downloads.
internet
Just this week, developers got some surprise news with a pull request adding support for the fetch API native to play in Node. Js, just a mere 6 years or so after it became an industry standard via WhatDoubleUG. Stop trying to make fetch happen. It's not going to happen. Fetch is not perfect, but it has proven itself to be good enough to where we don't need to wrap it with a 1,000,000,000 other packages just to avoid mental health issues. But why is this a big deal? Well, fetch provides a generic definition of request and response objects and allows you to manage them with to pull promise based API. Because fetch and node is pretty much identical to the browser, developers have less mental overhead when translating between front end and back end code. Sharing and common APIs also makes it much easier to develop packages that work both in Node and the browser. It's something that other runtimes like Deno and Cloudflare workers have already implemented. So they deserve some credit for giving Node some friendly competition. Fetch sounds cool, so how do I use it? As of today, it's not in a public release, but you could build Node from source if you're really motivated.
Keep your eyes peeled for Node version 17.5, where it should be available under an experimental flag, to then expect it to be a standard issue weapon by Node 18. The implementation is based on a package you can use today called undici, which is named after the character to leaven in Stranger Things.
weapons
We can install it in a Node project then import fetch. It makes scripting in Node really nice because to make a git request, All we have to do is await fetch to access data from any website or API. And, we don't even need an async function because node also supports top level await. Now, to make a post request, we can use the same function and modify some of its options like the method, body, and headers. That's pretty nice, but one question on a lot of people's minds is what does this mean for axios? Deos. In my opinion, I think there will still be a place for third party libraries, but the vast majority of projects will be able to get by with what's built into Node, instead of reaching to install to a third party package for every project.
Speaking of things that are dead, in other news, I'm sad to report that our Twitter bot, Bob, has been terminated. It's my fault because I didn't realize that building Twitter bots with OpenAI is not allowed. I feel terrible about this, but I really don't wanna lose my API key because I have a lot of their cool ideas for OpenAI.
twitter
Bob had a short but impactful life, and apparently, he meant a lot of different things to a lot of different people. His final words before I pulled the plug were I'll be back. I don't wanna end this video on a sad note, so in other more uplifting news, Facebook or Meta was down 25% yesterday, and Zuckerberg's net worth declined by about $30,000,000,000 This has been the Code Report. Thanks for watching, and I will see you in the next one.
It is February 4, 2022, and you're watching the Code Report, news you can use. JavaScript developers are famous for their ability to reinvent the wheel. In Node. Js, for example, there are many ways to work with the hypertext transfer protocol. If you hate yourself, you might use its built in HTTP module, tool, but there is a smorgasbord of third party packages like Axios, NodeFetch, Got, Request, Super Agent, and hundreds of others. They're extremely popular and account for tens of millions of weekly downloads. Just this week, developers got some surprise news with a pull request adding support for the fetch API native to play in Node. Js, just a mere 6 years or so after it became an industry standard via WhatDoubleUG. Stop trying to make fetch happen. It's not going to happen. Fetch is not perfect, but it has proven itself to be good enough to where we don't need to wrap it with a 1,000,000,000 other packages just to avoid mental health issues. But why is this a big deal? Well, fetch provides a generic definition of request and response objects and allows you to manage them with to pull promise based API. Because fetch and node is pretty much identical to the browser, developers have less mental overhead when translating between front end and back end code. Sharing and common APIs also makes it much easier to develop packages that work both in Node and the browser. It's something that other runtimes like Deno and Cloudflare workers have already implemented. So they deserve some credit for giving Node some friendly competition. Fetch sounds cool, so how do I use it? As of today, it's not in a public release, but you could build Node from source if you're really motivated. Keep your eyes peeled for Node version 17.5, where it should be available under an experimental flag, to then expect it to be a standard issue weapon by Node 18. The implementation is based on a package you can use today called undici, which is named after the character to leaven in Stranger Things. We can install it in a Node project then import fetch. It makes scripting in Node really nice because to make a git request, All we have to do is await fetch to access data from any website or API. And, we don't even need an async function because node also supports top level await. Now, to make a post request, we can use the same function and modify some of its options like the method, body, and headers. That's pretty nice, but one question on a lot of people's minds is what does this mean for axios? Deos. In my opinion, I think there will still be a place for third party libraries, but the vast majority of projects will be able to get by with what's built into Node, instead of reaching to install to a third party package for every project. Speaking of things that are dead, in other news, I'm sad to report that our Twitter bot, Bob, has been terminated. It's my fault because I didn't realize that building Twitter bots with OpenAI is not allowed. I feel terrible about this, but I really don't wanna lose my API key because I have a lot of their cool ideas for OpenAI. Bob had a short but impactful life, and apparently, he meant a lot of different things to a lot of different people. His final words before I pulled the plug were I'll be back. I don't wanna end this video on a sad note, so in other more uplifting news, Facebook or Meta was down 25% yesterday, and Zuckerberg's net worth declined by about $30,000,000,000 This has been the Code Report. Thanks for watching, and I will see you in the next one.
It
it
is
is
February
february
4,
4
2022,
2022
and
and
you're
you're
watching
watching
the
the
Code
code
Report,
report
news
news
you
you
can
can
use.
use
JavaScript
javascript
developers
developers
are
are
famous
famous
for
for
their
their
ability
ability
to
to
reinvent
reinvent
the
the
wheel.
wheel
In
in
Node.
node
Js,
js
for
for
example,
example
there
there
are
are
many
many
ways
ways
to
to
work
work
with
with
the
the
hypertext
hypertext
transfer
transfer
protocol.
protocol
If
if
you
you
hate
hate
yourself,
yourself
you
you
might
might
use
use
its
its
built
built
in
in
HTTP
http
module,
module
tool,
tool
but
but
there
there
is
is
a
a
smorgasbord
smorgasbord
of
of
third
third
party
party
packages
packages
like
like
Axios,
axios
NodeFetch,
nodefetch
Got,
got
Request,
request
Super
super
Agent,
agent
and
and
hundreds
hundreds
of
of
others.
others
They're
they're
extremely
extremely
popular
popular
and
and
account
account
for
for
tens
tens
of
of
millions
millions
of
of
weekly
weekly
downloads.
downloads
Just
just
this
this
week,
week
developers
developers
got
got
some
some
surprise
surprise
news
news
with
with
a
a
pull
pull
request
request
adding
adding
support
support
for
for
the
the
fetch
fetch
API
api
native
native
to
to
play
play
in
in
Node.
node
Js,
js
just
just
a
a
mere
mere
6
6
years
years
or
or
so
so
after
after
it
it
became
became
an
an
industry
industry
standard
standard
via
via
WhatDoubleUG.
whatdoubleug
Stop
stop
trying
trying
to
to
make
make
fetch
fetch
happen.
happen
It's
it's
not
not
going
going
to
to
happen.
happen
Fetch
fetch
is
is
not
not
perfect,
perfect
but
but
it
it
has
has
proven
proven
itself
itself
to
to
be
be
good
good
enough
enough
to
to
where
where
we
we
don't
don't
need
need
to
to
wrap
wrap
it
it
with
with
a
a
1,000,000,000
1,000,000,000
other
other
packages
packages
just
just
to
to
avoid
avoid
mental
mental
health
health
issues.
issues
But
but
why
why
is
is
this
this
a
a
big
big
deal?
deal
Well,
well
fetch
fetch
provides
provides
a
a
generic
generic
definition
definition
of
of
request
request
and
and
response
response
objects
objects
and
and
allows
allows
you
you
to
to
manage
manage
them
them
with
with
to
to
pull
pull
promise
promise
based
based
API.
api
Because
because
fetch
fetch
and
and
node
node
is
is
pretty
pretty
much
much
identical
identical
to
to
the
the
browser,
browser
developers
developers
have
have
less
less
mental
mental
overhead
overhead
when
when
translating
translating
between
between
front
front
end
end
and
and
back
back
end
end
code.
code
Sharing
sharing
and
and
common
common
APIs
apis
also
also
makes
makes
it
it
much
much
easier
easier
to
to
develop
develop
packages
packages
that
that
work
work
both
both
in
in
Node
node
and
and
the
the
browser.
browser
It's
it's
something
something
that
that
other
other
runtimes
runtimes
like
like
Deno
deno
and
and
Cloudflare
cloudflare
workers
workers
have
have
already
already
implemented.
implemented
So
so
they
they
deserve
deserve
some
some
credit
credit
for
for
giving
giving
Node
node
some
some
friendly
friendly
competition.
competition
Fetch
fetch
sounds
sounds
cool,
cool
so
so
how
how
do
do
I
i
use
use
it?
it
As
as
of
of
today,
today
it's
it's
not
not
in
in
a
a
public
public
release,
release
but
but
you
you
could
could
build
build
Node
node
from
from
source
source
if
if
you're
you're
really
really
motivated.
motivated
Keep
keep
your
your
eyes
eyes
peeled
peeled
for
for
Node
node
version
version
17.5,
17.5
where
where
it
it
should
should
be
be
available
available
under
under
an
an
experimental
experimental
flag,
flag
to
to
then
then
expect
expect
it
it
to
to
be
be
a
a
standard
standard
issue
issue
weapon
weapon
by
by
Node
node
18.
18
The
the
implementation
implementation
is
is
based
based
on
on
a
a
package
package
you
you
can
can
use
use
today
today
called
called
undici,
undici
which
which
is
is
named
named
after
after
the
the
character
character
to
to
leaven
leaven
in
in
Stranger
stranger
Things.
things
We
we
can
can
install
install
it
it
in
in
a
a
Node
node
project
project
then
then
import
import
fetch.
fetch
It
it
makes
makes
scripting
scripting
in
in
Node
node
really
really
nice
nice
because
because
to
to
make
make
a
a
git
git
request,
request
All
all
we
we
have
have
to
to
do
do
is
is
await
await
fetch
fetch
to
to
access
access
data
data
from
from
any
any
website
website
or
or
API.
api
And,
and
we
we
don't
don't
even
even
need
need
an
an
async
async
function
function
because
because
node
node
also
also
supports
supports
top
top
level
level
await.
await
Now,
now
to
to
make
make
a
a
post
post
request,
request
we
we
can
can
use
use
the
the
same
same
function
function
and
and
modify
modify
some
some
of
of
its
its
options
options
like
like
the
the
method,
method
body,
body
and
and
headers.
headers
That's
that's
pretty
pretty
nice,
nice
but
but
one
one
question
question
on
on
a
a
lot
lot
of
of
people's
people's
minds
minds
is
is
what
what
does
does
this
this
mean
mean
for
for
axios?
axios
Deos.
deos
In
in
my
my
opinion,
opinion
I
i
think
think
there
there
will
will
still
still
be
be
a
a
place
place
for
for
third
third
party
party
libraries,
libraries
but
but
the
the
vast
vast
majority
majority
of
of
projects
projects
will
will
be
be
able
able
to
to
get
get
by
by
with
with
what's
what's
built
built
into
into
Node,
node
instead
instead
of
of
reaching
reaching
to
to
install
install
to
to
a
a
third
third
party
party
package
package
for
for
every
every
project.
project
Speaking
speaking
of
of
things
things
that
that
are
are
dead,
dead
in
in
other
other
news,
news
I'm
i'm
sad
sad
to
to
report
report
that
that
our
our
Twitter
twitter
bot,
bot
Bob,
bob
has
has
been
been
terminated.
terminated
It's
it's
my
my
fault
fault
because
because
I
i
didn't
didn't
realize
realize
that
that
building
building
Twitter
twitter
bots
bots
with
with
OpenAI
openai
is
is
not
not
allowed.
allowed
I
i
feel
feel
terrible
terrible
about
about
this,
this
but
but
I
i
really
really
don't
don't
wanna
wanna
lose
lose
my
my
API
api
key
key
because
because
I
i
have
have
a
a
lot
lot
of
of
their
their
cool
cool
ideas
ideas
for
for
OpenAI.
openai
Bob
bob
had
had
a
a
short
short
but
but
impactful
impactful
life,
life
and
and
apparently,
apparently
he
he
meant
meant
a
a
lot
lot
of
of
different
different
things
things
to
to
a
a
lot
lot
of
of
different
different
people.
people
His
his
final
final
words
words
before
before
I
i
pulled
pulled
the
the
plug
plug
were
were
I'll
i'll
be
be
back.
back
I
i
don't
don't
wanna
wanna
end
end
this
this
video
video
on
on
a
a
sad
sad
note,
note
so
so
in
in
other
other
more
more
uplifting
uplifting
news,
news
Facebook
facebook
or
or
Meta
meta
was
was
down
down
25%
25%
yesterday,
yesterday
and
and
Zuckerberg's
zuckerberg's
net
net
worth
worth
declined
declined
by
by
about
about
$30,000,000,000
$30,000,000,000
This
this
has
has
been
been
the
the
Code
code
Report.
report
Thanks
thanks
for
for
watching,
watching
and
and
I
i
will
will
see
see
you
you
in
in
the
the
next
next
one.
one
success
In this news report, the host discusses various ways developers can use the fetch API for their work, including using it for building websites and applications. They also mention a terminated Twitter bot and a decline in net worth for working on a project. The host provides information on various projects and expresses sadness about the situation.
BIG new feature lands in Node.js // The Code Report
It is February 4, 2022, and you're watching the Code Report, news you can use. JavaScript developers are famous for their ability to reinvent the wheel. In Node. Js, for example, there are many ways to work with the hypertext transfer protocol. If you hate yourself, you might use its built in HTTP module, tool, but there is a smorgasbord of third party packages like Axios, NodeFetch, Got, Request, Super Agent, and hundreds of others. They're extremely popular and account for tens of millions of weekly downloads. Just this week, developers got some surprise news with a pull request adding support for the fetch API native to play in Node. Js, just a mere 6 years or so after it became an industry standard via WhatDoubleUG. Stop trying to make fetch happen. It's not going to happen. Fetch is not perfect, but it has proven itself to be good enough to where we don't need to wrap it with a 1,000,000,000 other packages just to avoid mental health issues. But why is this a big deal? Well, fetch provides a generic definition of request and response objects and allows you to manage them with to pull promise based API. Because fetch and node is pretty much identical to the browser, developers have less mental overhead when translating between front end and back end code. Sharing and common APIs also makes it much easier to develop packages that work both in Node and the browser. It's something that other runtimes like Deno and Cloudflare workers have already implemented. So they deserve some credit for giving Node some friendly competition. Fetch sounds cool, so how do I use it? As of today, it's not in a public release, but you could build Node from source if you're really motivated. Keep your eyes peeled for Node version 17.5, where it should be available under an experimental flag, to then expect it to be a standard issue weapon by Node 18. The implementation is based on a package you can use today called undici, which is named after the character to leaven in Stranger Things. We can install it in a Node project then import fetch. It makes scripting in Node really nice because to make a git request, All we have to do is await fetch to access data from any website or API. And, we don't even need an async function because node also supports top level await. Now, to make a post request, we can use the same function and modify some of its options like the method, body, and headers. That's pretty nice, but one question on a lot of people's minds is what does this mean for axios? Deos. In my opinion, I think there will still be a place for third party libraries, but the vast majority of projects will be able to get by with what's built into Node, instead of reaching to install to a third party package for every project. Speaking of things that are dead, in other news, I'm sad to report that our Twitter bot, Bob, has been terminated. It's my fault because I didn't realize that building Twitter bots with OpenAI is not allowed. I feel terrible about this, but I really don't wanna lose my API key because I have a lot of their cool ideas for OpenAI. Bob had a short but impactful life, and apparently, he meant a lot of different things to a lot of different people. His final words before I pulled the plug were I'll be back. I don't wanna end this video on a sad note, so in other more uplifting news, Facebook or Meta was down 25% yesterday, and Zuckerberg's net worth declined by about $30,000,000,000 This has been the Code Report. Thanks for watching, and I will see you in the next one.
In this news report, the host discusses various ways developers can use the fetch API for their work, including using it for building websites and applications. They also mention a terminated Twitter bot and a decline in net worth for working on a project. The host provides information on various projects and expresses sadness about the situation.