我有https://github.com/HackerNews/API的问题。
我需要在第一页的 30 条新闻(标题、作者...)中获取 Angular 7 中的所有最佳新闻。如何使用下一个 api 发送 get 请求?
此 API 显示最佳故事的所有 ID:https : //hacker-news.firebaseio.com/v0/topstories.json?print=pretty
这个 api 展示了一个故事的例子:https : //hacker-news.firebaseio.com/v0/item/8863.json?print=pretty
我试试这个:
loadItem(){
this.http.get(`https://hacker-
news.firebaseio.com/v0/item/${this.id}.json?print=pretty`).subscribe(data => {
this.items.push(data as any[]);
})
}
loadBestItems(){
this.http.get('https://hacker-news.firebaseio.com/v0/beststories.json?
print=pretty').subscribe(data => {
this.bestItems.push(data as any[]);
})
}
Run Code Online (Sandbox Code Playgroud)
我需要第一页上的 30 条最佳新闻