Design comparison
SolutionDesign
Solution retrospective
What do you think of the way that the API was fetched?
Thanks
Community feedback
- @vanzasetiaPosted over 2 years ago
Hello, Miguel Zapata! š
Regarding the way you fetch the API, I think you can simplify it by grouping the error handling and the response as one function. After that, you can make that function returns the JSON data.
const fetchUserData = async (username) => { try { const response = await fetch(`https://api.github.com/users/${username}`); const json = await response.json(); /* do something with the json */ } catch (error) { /* handle error */ } }
Some more suggestions.
- The moon and the sun icons are decorative images. So, I recommend adding
aria-hidden="true"
andfocusable="false"
attributes to thesvg
. This way, those icons will be hidden from the screenreader users. - I recommend using
hidden
attribute instead of using.hidden
class. - Always specify the
type
of thebutton
. In this case, set the type of them astype="submit"
. It will prevent the button from behaving unexpectedly. - Location is just plain text (not a link).
- If you want to make the company as plain text then I recommend swapping the anchor tag with
span
instead. Assistive technology might still pronounce it as a link (even without thehref
attribute).
That's it! I hope you find this useful!
Marked as helpful1 - The moon and the sun icons are decorative images. So, I recommend adding
- @ChristopherParkePosted over 2 years ago
Looks good. My only note would be that yes the API fetch works, but it would be better in a framework like React or Vue. That's because it would be more portable and easier for others to understand and use your code. Great work though. Basically perfect.
Marked as helpful1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord