UpdateOne Result is Undefined once Deployed to Heroku

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)
         }
       })
     }

This issue can be closed. I had a typo in a setting connecting to the Database.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.