From b1875d8d9920b8bf640ac9e7dfb5dee164ea4dfa Mon Sep 17 00:00:00 2001 From: adrian-burkhart Date: Fri, 3 Feb 2023 15:47:19 +0100 Subject: [PATCH] Update answer to question 303 --- README.md | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ff18d672..57aa12cc 100644 --- a/README.md +++ b/README.md @@ -6404,25 +6404,20 @@ Learn to code and get hired with { - (async () => { - const result = await axios( - "http://hn.algolia.com/api/v1/search?query=react" - ); - - setData(result.data); - })(); + React.useEffect(() => { + fetch("http://hn.algolia.com/api/v1/search?query=react") + .then(response => response.json()) + .then(data => setData(data)) }, []); return ( @@ -6439,7 +6434,9 @@ Learn to code and get hired with