I want to make a quick Util file which would contain multiple functions such as an user\_id to his name. As the image under shows, I tried to save the value throughout the code but the variable "name" doesn't get affected inside the `.then(user => {})` for some reasons

I tried returning directly the value without using variable to save it.
I debugged and code runs fine and it gets into the `if(!user){}else{}`perfectly.
The user returned by Mongoose works and I can console log the user.username (Cannot return it, either can I save it to a variable, which is what i'm doing on the code under)

```js
const User = require('../models/users')

exports.id2name = (id) => {
  let name = 'none'
  User.findOne({_id: id}).then(user => {
    if (!user) {
      name = 'Unknown'
    } else {
      name = user.username
    }
  }).catch(err => console.log(err))
  return name
}

```

I don't get any errors on my console. It is returning 'none' as a result even if it gets into the else statement inside the mongoose request.