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;