我刚开始学习Angular 2我正在尝试使用get调用来访问URL,但是即使在浏览器的网络中,get似乎也没有通过我无法找到获取URL的URL.
该程序将进入上面和下面的方法控制台记录,但是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");
}
Run Code Online (Sandbox Code Playgroud)
进口HttpModule在app.module.ts
我的控制台屏幕截图
![安慰]](https://i.stack.imgur.com/w9AeE.png)