简体   繁体   中英

How to make Https call in Angular2

Using Angular2 I have been making HTTP calls like this:

var headers = new Headers();
// headers.append('Content-Type', 'application/json');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.http.post(
    'http://192.168.1.100',
    {headers: headers}
).map(
    (res:Response)=>res.json())
    .subscribe(
        (response) => {



        },
        (err) => {

        },
        () => {

        }
    ); //end of subscribe

I know need to make a call to Facebook's API which requires HTTPS, but I can't find in Angular2 docs anything about HTTPS calls. How do you make a HTTPS call in Angular2?

There is nothing else to do than specifying the https protocol in the URL you provide when using methods of the Http class:

this.http.post(
    'https://some-address',
    {headers: headers}
).map(...);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM