Now that we logged in and have the network tab open inside of Chrome Tools, let's take a look at the
request we have first here.
So this is the log in request inside of Postman or inside of Chrome tools.
We can see that it's a post request.
It has a URL here and it has a lot of headers and cookies.
It's being set.
That's been set.
Now you can see my form data for the form here.
And yeah, that's my password.
I'm okay with the password.
I will change it.
And I actually don't care about this account so much.
So that's the form data that's being sent and that's all the headers.
Now, a quick tip if you want to test this request inside of Postman and not have to copy all the headers
manually and the form data, we can right click here and say copy and copy as curl request and then
let's go inside of Postman.
And let's open up a new request here.
And let's say import.
And paste raw text and just paste in the curl request here.
And then Postman fills up the request with all the headers and the body already being set, which is
really convenient.
Then we can test.
Does the request still work inside of Postman and we can see it still works.
It says you're already logged in.
It's okay because I am actually already logged in.
It sees that the cookie is already logged in in this session.
So what we want to do now is to replicate this inside of NodeJS request.
So how can we do that?
Well, let's try and see how much you need to be able to do this request here.
If I disable the cookie here and I also delete the cookies inside of Postman.
By clicking on the cookies up here in the corner, clearing them all out.
And if I don't have the cookies set down here in the request, well.
Then we get a 403 forbidden.
That means that the request is forbidden.
And it says something about csrf.
The request you are the request is not allowed.
So we need to have cookies set on this request.
And the cookies are initially being set when we go on to the front page of this website.
So if I try to log out here.
The cookies are originally being set just as we visit this website.
And that's sometimes the case with these authentication websites that you have to visit one website,
have a cookie being set, and then you can log in onto the website when you have this cookie set.
So you have to do that inside NodeJS requests sometimes.
And let me show you now how we can do that.