Great post! I might have to go play with this news API sometime.
One possible improvement in code clarity: in your getNews function, should this
getNews
let result = await fetch(url).then(response => response).then(response => response.json());
be replaced with this?
let result = await fetch(url).then(response => response.json());
Since you're just passing it along to the next then call, it seems redundant to me and could be removed to make the code a little more clear. If you do have a reason for doing it that way, I'd love to hear why!
then
thanks, i might've forgot that i added the await keyword.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great post! I might have to go play with this news API sometime.
One possible improvement in code clarity: in your
getNews
function, should thisbe replaced with this?
Since you're just passing it along to the next
then
call, it seems redundant to me and could be removed to make the code a little more clear. If you do have a reason for doing it that way, I'd love to hear why!thanks, i might've forgot that i added the await keyword.