I make an axios call from my front-end to my Express backend, which contains the following code. In my Development environment, everything works perfectly and a nonce is returned to the front-end. However, once my app has been deployed to Heroku and my Mongodb database to the Mongo Atlas platform, the “result” returns as undefined, although I have confirmed that the database is being updated properly with a nonce. Why is this?
app.post('/api/login', (req, res) => {
...
nonce = nonceValue
var updateValue = { $set: {nonce: nonce} }
db.collection("Users").updateOne(query, updateValue, (err, result) => {
if (result) { // Is Undefined
res.send(`${nonce}`)
} else {
res.send(null)
}
})
}