相关疑难解决方法(0)

Angular 2 http得不到

我刚开始学习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

我的控制台屏幕截图

安慰]

angular-http angular

47
推荐指数
1
解决办法
4万
查看次数

标签 统计

angular ×1

angular-http ×1