Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
userId is not defined

So i managed to get username from a link but im unsure of how to actually get the userid back. I want it so when it to say the username which works perfectly, but down in thumbnail when i try to fetch the userId it comes up as "userId is not defined". I'm it sure what the solution is but I want to keep both userId and username. here is my code!

const getUsername = userId => new Promise(resolve => {
    fetch('https://users.roblox.com/v1/users/' + userId)
    .then(res => res.json())
    .then(body => resolve(body.name || 'Unknown'))
    .catch(() => resolve('Unknown'))
})
            (async () => {
                const username = await getUsername(nextInQueue.offers[0].userId);
                consola.success(`[${username}] has ok items`)
                
                fetch(config.webhook, {
                    method: 'POST',
                    headers: {
                        'content-type': 'application/json'
                    },
                    body: JSON.stringify({
                        "content": null,
                        "embeds": [
                            {
                                "title": ":tada: Trade sent to: " + username + " :tada:",
                                "color": 28420,
                                "fields": [
                                    {
                                        "name": "Cool Items:",
                                        "value": itemNameList.join('\n')
                                    },
                                    {
                                        "name": "Okay items:",
                                        "value": toreceiveList.join('\n')
                                    }
                                ],
                                "author": {
                                  "name": "Expoorttoo",
                                  "icon_url": "https://i.pinimg.com/736x/4b/69/74/4b6974aef5d96580140ef2686072af3f.jpg"
                                },
                                "footer": {
                                    "text": Sentto.toLocaleString() + " sent & " + tradeQueue.length.toLocaleString() + " set in queue"
                                },
                                "thumbnail": {
                                    "url": "https://www.roblox.com/headshot-thumbnail/image?userId=" + userId + "&width=420&height=420&format=png"
                                }
                            }
                        ]
                    })
                })
            })().catch();
        }

oh yeah by the way its a webhook which it sends to on discord. It works without thumbnail but doesnt work with the thumbnail saying userid.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are missing

const userId = nextInQueue.offers[0].userId;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!