My problem is that I would like to return the value of a variable gotten from fetch outside of the fetch function. This is my current code:
const fetch = require('node-fetch');
var playerName = "kada49";
async function fetchUUID() {
const response = await fetch(`https://api.mojang.com/users/profiles/minecraft/${playerName}`);
const data = await response.json();
return data;
}
fetchUUID()
.then(data => {
let playerUUID = data.id;
return playerUUID;
});
var playerUUID = fetchUUID();
console.log(playerUUID);
as a response I get this in the console:
Promise { <pending> }
WHat am I doing wrong?