Skip to content

Commit 84b162f

Browse files
authoredMar 6, 2024··
docs: Fixed asynchronous error in NewsService list method by adding '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.
1 parent 9957b9c commit 84b162f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎site/docs/intro/quickstart.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ class NewsService extends Service {
275275

276276
// parallel GET detail
277277
const newsList = await Promise.all(
278-
Object.keys(idList).map((key) => {
278+
Object.keys(idList).map(async (key) => {
279279
const url = `${serverUrl}/item/${idList[key]}.json`;
280-
return this.ctx.curl(url, { dataType: 'json' });
280+
return await this.ctx.curl(url, { dataType: 'json' });
281281
}),
282282
);
283283
return newsList.map((res) => res.data);

0 commit comments

Comments
 (0)
Please sign in to comment.