In the previous section you saw that we couldn't get any further with our request because it was being
cached in this try catch clause.
It was throwing an exception.
Even though we're just getting a free O2 status code, which means we actually need to redirect.
In order to make requests.
Promise not treat the free O2 status code as a error.
We need to pass in an option saying simple is false.
Once we've done that, you can actually try and get the result.
But since the body of this result is going to be empty if I press node index.js.
You see, there is no result here because the body is empty of this request.
But if we go and say resolve with full response and set that to true request is going to.
Resolve the assault here with a full response so we can look inside of the header status code and so
on.
Now, if I go and say node Index.js again.
I get a pretty big object containing all of the data.
Now, when you get this response, the location or the URL that you want to go next to is located on
the headers and location.
So we're going to save that and try and run it again.
Now we get a URL here, but there is a notice here about us having a unsupported browser here.
So that means we can try and fake what kind of browser we are using by setting the user agent header
in our request.
So I think it's about time now that we make a default options object for all of our requests now.
So follow along with me and create this default options.
And here we set the headers, which is also a object, and we set the user agent here.
And what user agent should we set?
Well, if we look inside of Firefox.
Where we made our our request once we try to log in and if you have the network tab open and you try
to log in on their mobile page using Firefox, you can look on there.
Um, the, the headers inside of this post request the request headers and here you can see our user
agent we're using.
So Firefox we see here.
So let me just copy that and then we can paste it inside of Visual Studio code.
So we just copy this whole string in, and that should be it.
Now let's try and run it again.
Oh, we're still getting unsupported browser because we need to use the default options in here.
So defaults.
Then we pass in default options.
And now we should be getting a nice URL.
So now we are getting this home dot php URL, which is actually our wall URL.
You could say for Facebook in the next section we're going to go ahead and make a request to this URL
and we should be getting our Facebook wall.