Closed smartgamer closed 4 years ago
Hello @smartgamer.
First of all your environment have to support async/await
if not you should use babel + browserify to transpile async/await
into a promise
(also dont forget to use
awaitkeyword only inside
asyncfunctions). Either you can use promise
.then()` method but your environment have to support promises anyway, if promises are not supported you can use babel or include pollyfills for promises yourself.
Example with .then()
:
let userAuth;
server.login({
password,
user: {
username,
},
}).then(function(token) {userAuth = token});
@Gregivy Thank you for your reply. It's solved now. I didn't know await has to be inside async.
Hi, When I tried to bundle the js file using browserify, : let userAuth = await server.login({ password, user: { username, }, });
I got an error message: SyntaxError: Unexpected token. This error happens at "await". If I remove "await", it seems work fine. Do you know what's the issue and how to solve this?
Thanks,