How would I go about using the value of username in other parts of my code? I've tried declaring it outside of the functions, but it didn't work. I've read that people used Callbacks do make something like this work, but I couldn't figure it out.
const https = require('https')
//const fs = require('fs')
function uuidCheck(req) {
var uuid = req.params.uuid // in url
https.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid, uuidToUsername)
function uuidToUsername (res) {
var body = ""
res.on("data", (chunk) => {
body += chunk
})
res.on("end", jsonStuff)
function jsonStuff () {
var username = JSON.parse(body).name;
console.log(`Found ${username}`)
//grab username variable to use in other parts of code
}
}
}
module.exports = {uuidCheck}