简体   繁体   中英

how to get json response from the below url

I have a Instagram url ( https://www.instagram.com/p/-vSJNUDKKD/?__a=1 ) which returns json ,but when i try to call the url with a http get request i am getting the entire html body.Where am i doing the mistake.

  public GetItems(url: string) {
    return this._http.get(url).map((response: Response) => response.json());
  }
  public downloadImage(url: string) {
    var myresult;
    this.GetItems(url + "?__a=1").subscribe((result) => {
      myresult = result;
      console.log(result);

    });

You should have an observable when you are subscribing to the http service.I tried with following code.Seems to be Working fine for me

getme(url):Observable<any>{
return this.http.get(url)
  .map((res:Response)=>{
    return res.json();
  })

}

and

 this.http.getme("https://www.instagram.com/p/-vSJNUDKKD/?__a=1").subscribe(
        res=> {

            console.log(res);
        })

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