So I'm trying to get a users username by id but I keep getting [object Promise]. I'm also trying to get their thumbnail but it doesn't show. These are my files
index.js
app.use('/', function(req, res) {
players.find({}, function(err, result) {
//if (err) return handleError(err);
if (err) return console.log(chalk.red(err));
return res.render('data', { result, getImage, getUser })
})
});
getFunction.js
async function getThumbnail(userID){
let data = await request({
uri: `https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds=${userID}&size=100x100&format=Png&isCircular=true`,
json: true,
simple: false
});
return data.data[0].imageUrl;
}
async function getUsername(userID){
let id = await userID;
let data = await request({
uri: `https://users.roblox.com/v1/users/${userID}`,
json: true,
simple: false
});
return data.name
}
//module.exports part
then the ejs file
<div class="row">
<% if(result.length){%>
<% for(var i = 0; i< result.length; i++) {%>
<% var userID = result[i].userID%>
<div class="column">
<div class="card">
<img src="<%= getImage(result[i].userID)%>" alt="Avatar" style="float:right;width:42px;height:42px;">
<h3>Username: <%= rbx.getUser(result[i].userID)%></h3>
<p>Reason: <%= result[i].reason%></p>
<p>Admin: <%= result[i].admin%></p>
<p><%= getImage(result[i].userID)%></p></div>
</div>
</div>
<%}%>
<%}else{ %>
<tr>
<td colspan="3">No user</td>
</tr>
<% } %>
Please help I'm out of ideas, I can't find any source on this so.