Open JuanR9910 opened 2 years ago
Postgres, Psql, Node,js
Having trouble retrieving comment data from the local database
router.get('/:id', (req, res) => { axios.get(https://rawg.io/api/games/${req.params.id}?key=${process.env.RAWG_API_KEY}) .then(apiRes => { console.log('this is apiRes', apiRes.data) const gameData = apiRes.data }) .then(()=> { db.comment.findAll({ where: {gameId:gameData.id} }) }) .then(dbRes => { console.log(dbRes) console.log("THIS IS OUR CONSOLE LOG", gameData) res.render('review.ejs', {gameData:gameData}) })
router.get('/:id', (req, res) => {
axios.get(
)
.then(apiRes => {
console.log('this is apiRes', apiRes.data)
const gameData = apiRes.data
})
.then(()=> {
db.comment.findAll({
where: {gameId:gameData.id}
.then(dbRes => {
console.log(dbRes)
console.log("THIS IS OUR CONSOLE LOG", gameData)
res.render('review.ejs', {gameData:gameData})
`.catch((error) => {` `res.status(400).render('main404')`
}) }) `
What error do you get when you make this api call? share it here as a comment or a screenshot
No error shows up in the terminal
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
Postgres, Psql, Node,js
What's the problem you're trying to solve?
Having trouble retrieving comment data from the local database
Post any code you think might be relevant (one fenced block per file)
router.get('/:id', (req, res) => {
axios.get(
https://rawg.io/api/games/${req.params.id}?key=${process.env.RAWG_API_KEY})
.then(apiRes => {
console.log('this is apiRes', apiRes.data)
const gameData = apiRes.data
})
.then(()=> {
db.comment.findAll({
where: {gameId:gameData.id}
})
})
.then(dbRes => {
console.log(dbRes)
console.log("THIS IS OUR CONSOLE LOG", gameData)
res.render('review.ejs', {gameData:gameData})
})
})
})
`If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
What things have you already tried to solve the problem?