JS Express server and Heroku API hosting.
I created a backend that allows me to Post and Get data from MongoDB through Express server that is hosted on Heroku, I'm using Postman for testing.
POST method works well both locally and on Heroku.
GET method only works locally and I get a Cannot GET / error with a 404 code when I test on Heroku.
This is my code below:
router.get('/posts', async (req, res) => {
try {
const posts = await Posts.find();
res.json(posts)
console.log('data',res.send)
}catch (err) {
res.send('error', err)
}
});
module.exports = router;