When I call the method interval, the parameter user, which I get from the method allUserStats, is always undefined. Here is the method
const interval = async () => {
    const allUsers = await getAllUser();
    for (const u of allUsers) {
            let user;
            let followerScore;
            let subscriberScore;
            //let hostsScore;
            let viewerScore;
            await getAllUserStats(u.login_name).then(async (userStats)=>{
                user = userStats;
...
The method getAllUserStats looks like this:
const getAllUserStats = async (login_name) => {
    await userstats.findOne({login_name}).then(async(userStats)=>{
        if(userStats===null){
            let user = new userstats({
                login_name:login_name,
                followers: [],
                subscribers: [],
                hosts: [],
                viewers: []
            })
            await user.save();
            return user;
        }
        else{
            return userStats;
        }
    })
}
I think it is an async-await issue, but I dont know. Any advice how I can fix that?
 
    