Hello,
I am making a discord bot where you can search for Roblox users either by UserId or Username; Problem is, I can’t get the username part to work. I am using the user API to get the username, but the data is empty:
async function getUserIdByUsername(username) {
const id_ = []
try {
const result = await
fetch('https://users.roproxy.com/v1/usernames/users', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: {
usernames: [
username
],
excludeBannedUsers: true,
}
})
console.log(username)
const json_res = await result.json()
console.log(json_res)
id_.push(json_res['data'][0]['id'])
} catch(err) {
throw new Error('Invalid username!', err);
}
return id_
}
Help is appreciated