Skip to content

Commit

Permalink
docs: Fixed asynchronous error in NewsService list method by adding '…
Browse files Browse the repository at this point in the history
…async' and 'await' (#5301)

This commit fixed an asynchronous error in the NewsService list method. I added the 'async' keyword and used 'await' to fetch data in each iteration. This ensures that the NewsService class can fetch news data from the Hacker News API efficiently and without errors.
  • Loading branch information
fainat authored Mar 6, 2024
1 parent 9957b9c commit 84b162f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions site/docs/intro/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ class NewsService extends Service {

// parallel GET detail
const newsList = await Promise.all(
Object.keys(idList).map((key) => {
Object.keys(idList).map(async (key) => {
const url = `${serverUrl}/item/${idList[key]}.json`;
return this.ctx.curl(url, { dataType: 'json' });
return await this.ctx.curl(url, { dataType: 'json' });
}),
);
return newsList.map((res) => res.data);
Expand Down

0 comments on commit 84b162f

Please sign in to comment.