I'm trying to pull out all the info from my api data for a detailed exercise page that will list the name, major muscle group, primary muscle worked. etc. The problem is that the info returned in main results have those categories listed as ids because then I need to enter a different parameter at the end of my root api in order to figure out the name to the ids given. For example this is what comes back from one exercise.
So I would then have to go to https://wger.de/api/v2/exercisecategory to pull out that category 10 = abs to have that display as the muscle group on my page
I'd have to do the same for the primary and secondary muscles worked with a different url.
My route looks like this:
router.get('/:exercise_id', (req, res) => {
let exerciseId = req.params.exercise_id
const exerciseApi = 'https://wger.de/api/v2/exercise/'
const eng = 'language=2'
axios.get(`${exerciseApi}${exerciseId}?${eng}`)
.then(apiRes => {
console.log('this is apiRes.data \n', apiRes.data)
let name = apiRes.data.name
let muscleGroup = apiRes.data.category
let description = apiRes.data.description
let primaryMuscle = apiRes.data.muscles[0]
let secondaryMuscle = apiRes.data.muscles[0]
res.render('search/details', {name, muscleGroup, description, primaryMuscle, secondaryMuscle})
})
.catch(error => {
console.error
})
})
Can I/would I have to input multiple axios.get with the correct url and create variables/gather info and compare all the data I'm getting back that way or would I have to create my own database that stores all names and id and compare the api results to my own db?
I'm trying to pull out all the info from my api data for a detailed exercise page that will list the name, major muscle group, primary muscle worked. etc. The problem is that the info returned in main results have those categories listed as ids because then I need to enter a different parameter at the end of my root api in order to figure out the name to the ids given. For example this is what comes back from one exercise.
https://wger.de/api/v2/exercise
So my details page on the frontend looks like
So I would then have to go to https://wger.de/api/v2/exercisecategory to pull out that category 10 = abs to have that display as the muscle group on my page
I'd have to do the same for the primary and secondary muscles worked with a different url.
My route looks like this:
Can I/would I have to input multiple axios.get with the correct url and create variables/gather info and compare all the data I'm getting back that way or would I have to create my own database that stores all names and id and compare the api results to my own db?