2

I made a workout app and I'm using Redux to save all of the sets and workouts. Right now I hand typed all of exercises into Redux data to test things out. I have all of the exercises in a .json file and I wanted to import it into the app so users would have access to them.

Would I need to import the .json file into Redux or different part of the app and then somehow give redux access to them? I confused because users would select the exercises and they can add descriptions, change number of sets and reps (which are all in Redux).

Edit

I'm new to coding hence why I haven't gone through the api route. I just want to get the beta version out. Also they are thousands of exercises in that .json file and that's why I haven't manually entered them into Redux.

4
  • Look into firebase. Create an account and upload the data on cloud firestore. Dispatch an action at the beginning to fetch the data and use it in your app. If you want to edit the data/ or if a user wants to add/change then you can easily change it on the backend via the frontend. Commented Oct 26, 2020 at 3:30
  • 1
    Instead of json file, you can store exercise data in redux and can access that data from redux so manipulation on data will store and update in redux Commented Oct 26, 2020 at 5:03
  • @NooruddinLakhani They are 3000 exercises so listing them in that file would make it very difficult. Unless I could put them in a file and then refer to them in redux. Commented Oct 27, 2020 at 20:28
  • @packability I have a backend setup with these int them but for simplicity and quick execution I wanted to know if there was an alternative way of doing it. I'm new to coding and have never anything with APIs. Commented Oct 27, 2020 at 20:29

1 Answer 1

1

You can read your local JSON file like this and then access exerciseData like a normal JS object

const exerciseData = require('./exerciseData.json');
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! So when I access these data would I need to do on redux side to let it become manipulatable? I hope that makes sense.
Yes exactly that completely make sense. Vote up if it helped thanks :-)
do you have any tips on how would I be able to correlate things from json file into redux after importing it? As in the name, description, sets, and reps would show up under name, description, sets, and reps within the app.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.