angular - 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>
解决方案
推荐阅读
- php - php 在现有 index.php 中添加 1 行
- chart.js - chart.js 标签文本字体大小和数字文本字体大小太小
- python - 从 matlab 移植到 python 的遗传算法似乎没有进化
- java - 尝试在 Android Studio 中的空对象引用上调用接口方法“java.lang.Object java.util.List.get(int)”
- python - 我必须创建嵌套循环还是可以使用 try 函数来创建?
- php - 如何将(合并的)下拉菜单值发送到数据库?
- javascript - JavaScript 中的对象创建和新对象
- css - 材质选择边框的颜色如何改变?
- android - 将日志写入流内的文件并在协程内收集
- python - 为什么这个 DataFrame 没有做我想做的事情?