JoshMerlino / namemc

The unofficial Node JS API for looking up Minecraft users on Name MC
https://www.npmjs.com/package/namemc
MIT License
13 stars 5 forks source link

Gives error when running the example code #1

Closed h0rb closed 3 years ago

h0rb commented 3 years ago

hello, I get this error when I run example code: `const users = await lookupName("tehpicix"); ^^^^^

SyntaxError: await is only valid in async function `

GroovyGab commented 3 years ago

That's not a package issue, The error is in the message, use a async function.

JoshMerlino commented 3 years ago

Because the functions return promises, I find it more elegant to use async/await - assuming it is in an async function.

You can fix this by wrapping it in:

(async function(){
    // await ...
}())