WEBVTT

00:01.500 --> 00:08.430
In the previous section you saw that we couldn't get any further with our request because it was being

00:08.430 --> 00:10.730
cached in this try catch clause.

00:10.740 --> 00:13.250
It was throwing an exception.

00:13.260 --> 00:19.890
Even though we're just getting a free O2 status code, which means we actually need to redirect.

00:20.880 --> 00:23.520
In order to make requests.

00:23.520 --> 00:28.230
Promise not treat the free O2 status code as a error.

00:28.410 --> 00:33.210
We need to pass in an option saying simple is false.

00:34.410 --> 00:39.390
Once we've done that, you can actually try and get the result.

00:40.970 --> 00:49.550
But since the body of this result is going to be empty if I press node index.js.

00:51.170 --> 00:57.950
You see, there is no result here because the body is empty of this request.

00:58.930 --> 01:08.440
But if we go and say resolve with full response and set that to true request is going to.

01:09.130 --> 01:15.700
Resolve the assault here with a full response so we can look inside of the header status code and so

01:15.700 --> 01:16.240
on.

01:16.930 --> 01:21.310
Now, if I go and say node Index.js again.

01:24.040 --> 01:28.720
I get a pretty big object containing all of the data.

01:29.620 --> 01:38.620
Now, when you get this response, the location or the URL that you want to go next to is located on

01:38.620 --> 01:41.320
the headers and location.

01:42.040 --> 01:45.610
So we're going to save that and try and run it again.

01:47.590 --> 01:56.130
Now we get a URL here, but there is a notice here about us having a unsupported browser here.

01:56.140 --> 02:04.930
So that means we can try and fake what kind of browser we are using by setting the user agent header

02:04.930 --> 02:06.760
in our request.

02:07.840 --> 02:16.060
So I think it's about time now that we make a default options object for all of our requests now.

02:16.960 --> 02:21.910
So follow along with me and create this default options.

02:24.470 --> 02:31.790
And here we set the headers, which is also a object, and we set the user agent here.

02:33.610 --> 02:35.860
And what user agent should we set?

02:35.890 --> 02:39.100
Well, if we look inside of Firefox.

02:39.930 --> 02:48.660
Where we made our our request once we try to log in and if you have the network tab open and you try

02:48.660 --> 02:54.900
to log in on their mobile page using Firefox, you can look on there.

02:55.440 --> 03:03.450
Um, the, the headers inside of this post request the request headers and here you can see our user

03:03.450 --> 03:04.470
agent we're using.

03:04.470 --> 03:07.530
So Firefox we see here.

03:09.410 --> 03:15.290
So let me just copy that and then we can paste it inside of Visual Studio code.

03:20.730 --> 03:26.430
So we just copy this whole string in, and that should be it.

03:27.570 --> 03:30.120
Now let's try and run it again.

03:33.200 --> 03:40.400
Oh, we're still getting unsupported browser because we need to use the default options in here.

03:40.400 --> 03:41.810
So defaults.

03:42.410 --> 03:45.740
Then we pass in default options.

03:47.510 --> 03:50.750
And now we should be getting a nice URL.

03:52.850 --> 03:59.930
So now we are getting this home dot php URL, which is actually our wall URL.

03:59.960 --> 04:06.590
You could say for Facebook in the next section we're going to go ahead and make a request to this URL

04:06.590 --> 04:09.290
and we should be getting our Facebook wall.
