hey guys I'm gonna show you quick we
tutorial on how to do HTTP requests with
well it's a fetch request with Nord
module called request for - ok so let's
get to it right so first thing first we
need to initialize package to Jason and
we don't care about that
don't care yeah that's fine okay and
then we're gonna create and X by givin
up dot GS file
okay and then we're gonna open the Jas
file and then we're going to install the
package called request so NPM I request
okie-dokie and we'll wait six months for
that to their mood and heard my voice
going really high pitch there okay so
cool we will require Const request
equals require request alright and then
we are going to use request and it takes
two parameters well you only need two
parameters to get it going so first of
all we need an object alright and we
need a callback
okay we don't need that middle option
ridiculous their goal and helps it you
can type okay so what do we pay in this
we object here we put em a URL of where
we're gonna go and only that much now
and we will be retrieving Jason they are
so we will say JSON and that will be
true okay and and here we need to add
three primers for it
first one is error know what kind of
error then it is response then we need
the body of the request okay and what
we're gonna do is we're gonna do this
just a basic tutorial nice and easy nice
and simple we're just gonna do console
blog body ok now I think I have still
got that website there we go we're gonna
retrieve all the posts from Jason
placeholder dot type ecoute typical comm
forward slash post now what this will do
is it will retrieve all the JSON data
and we will be able to log it to the
console okay that's fun so there clear
all that's down here and we do node oh
by the way I call this up yes yeah right
and we will gender and oh boy did that
Deema
why did that do that I figured it out
quite and didn't actually save the file
that's why like okay so I've cleared
that and that's from that again I'm look
at that
a hundred posts retrieved using no GS
and I think we could clean this up a
little more using a little trick so if
we do json dot stringify okay string by
the body and then we don't need a
replace her undefined and the last one
is how many spaces of indentation do you
want
I prefer four okay so we're gonna do
four and then we will clear this and
we'll run it again okay see how that's
nice and neat now yeah you can read them
all properly pretty cool pretty cool
okay that's it
Cheers bye for now