From 84b162faecf9cfed2e7156866ce1bf8bfff4ad93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Infab=20=E2=80=A2?= <73039554+fainat@users.noreply.github.com> Date: Wed, 6 Mar 2024 13:36:25 +0500 Subject: [PATCH] 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. --- site/docs/intro/quickstart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/docs/intro/quickstart.md b/site/docs/intro/quickstart.md index 8162f81329..1e1934b818 100644 --- a/site/docs/intro/quickstart.md +++ b/site/docs/intro/quickstart.md @@ -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);