角2 http得不到

角2 http得不到

我刚进入角形2,还在学习我尝试用GET调用来点击URL,但是GET似乎没有经过,即使在浏览器的网络中,我也找不到被调用的GET URL。

程序将转到该方法控制台,记录在GET调用上面和下面,但对于get调用没有任何记录。

我的服务方法

import { Headers, Http, Response } from '@angular/http';
import { Injectable } from '@angular/core';
import { Persons } from './mock-people';
import { Person } from './person';
import {Observable} from 'rxjs/Rx';

getAllPersons(): void {
  console.log("Here");
  this.http.get(`http://swapi.co/api/people/1`)
    .map((response: Response) => {
      console.log(response.json());
      response.json();
    });
  console.log("Comes here 2");
}

进口HttpModule在app.module.ts中

我的控制台屏幕截图


杨__羊羊
浏览 534回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP