首页 > 解决方案 > Ratp 得到 angular5

问题描述

我有一个小问题,我无法通过链接网络获取数据 在此处输入图像描述

我使用 Angular5

ratp.service.ts

getDatas(){
    const url = "https://data.ratp.fr/explore/dataset/liste-des-commerces-de-proximite-agrees-ratp/api/?disjunctive.code_postal&sort=code_postal&refine.tco_libelle=Le+Narval";
    const headers = new HttpHeaders()
       .append('Content-Type', 'application/json')
       .append('Access-Control-Allow-Origin', '*')
       .append('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, authorization,Client-Security-Token')
       .append('Access-Control-Allow-Methods', 'GET, PUT, POST, PATCH, DELETE, OPTIONS');

    return this.http.get<any>(url,{headers} ).pipe(map(res => console.log(res)));
}

app.component.ts

test(){
   this.ratp.getDatas().subscribe(res => res);
}

app.component.html

<button (click)="test()">Click</button>

标签: angular

解决方案



推荐阅读