I have the following code:

exports.dashboardUpdateNote = async (req, res, next) => {
    var updateNote = {
        "title": req.body.title,
        "body": req.body.body1,
    }
    await Note.findOneAndUpdate({ _id: req.body.note_id }, { $set: updateNote })
        .then((Successful) => {
            console.log('Successful: ', Successful)
        })
    return res.redirect('/dashboard')
}

It redirected but no changes(updates) occure.
Then I made this change in the code(Adding: { upsert: true }):

exports.dashboardUpdateNote = async (req, res, next) => {
    var updateNote = {
        "title": req.body.title,
        "body": req.body.body1,
    }
    await Note.findOneAndUpdate({ _id: req.body.note_id }, { $set: updateNote }, { upsert: true })
        .then((Successful) => {
            console.log('Successful: ', Successful)
        })
    return res.redirect('/dashboard')
}

It redirected and the changes(updates) occured, but when I click the (note) which I have updated to view it it gives this error:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:399:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.header (C:UsershpNODENotesnode_modulesexpresslibresponse.js:794:10)     
    at ServerResponse.contentType (C:UsershpNODENotesnode_modulesexpresslibresponse.js:624:15)
    at ServerResponse.send (C:UsershpNODENotesnode_modulesexpresslibresponse.js:149:14)       
    at done (C:UsershpNODENotesnode_modulesexpresslibresponse.js:1035:10)
    at tryHandleCache (C:UsershpNODENotesnode_modulesejslibejs.js:280:5)
    at exports.renderFile [as engine] (C:UsershpNODENotesnode_modulesejslibejs.js:491:10)     
    at View.render (C:UsershpNODENotesnode_modulesexpresslibview.js:135:8)
    at tryRender (C:UsershpNODENotesnode_modulesexpresslibapplication.js:657:10)

But when I click a note which I never updeted to view it no error occurs and the note appears.