Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

React.js, styled-components, javascript

#react#styled-components

@CreatorLZ

Desktop design screenshot for the Expenses chart component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


I've got no clue on how to use fetch api. previously, i had only used axios to make server requests and could not employ it in this project. i had to improvise and convert the data.json file to data.js and map through its content.

Community feedback

P

@seapagan

Posted

Using fetch to get a local JSON file is not so complicated; just remember it returns a promise, so you should await it and then convert it back to JSON. For the provided file it can be done in one line :

const data = await fetch("data.json").then((res) => res.json());

Then just iterate over the data object using a forEach or similar. You may need to specify a path for the JSON file depending on where you put it in relation to your component.

Marked as helpful

1

@CreatorLZ

Posted

@seapagan Thanks man. I'm using this in whatever I'll build next

1
P

@seapagan

Posted

@CreatorLZ you're very welcome 😀

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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