A minor change from your suggestion, as .setCredentials() isn't async to my knowledge and I think userinfo.get() is. Feel free to correct me if I'm wrong.
Again thanks for your suggestion and will update the post accordingly.
I think it's ok. Async/Await is an amazing ES6 feature, keep going with that. You might forget about the callback hell.
And one more thing. Await can be used with the sync functions. It just does nothing if you make a mistake. E.g.
constasyncMethod=()=>{returnnewPromise(resolve=>{setTimeout(()=>resolve('Hello'),1000);});}constsyncMethod=()=>{return'World';}functionasyncgreeting=()=>{consthello=awaitasyncMethod();// below await is not needed, but it works tooconstworld=awaitsyncMethod();console.log(hello,world);// logs Hello World}
Of course, you don't have to put await anywhere, but if you don't know if the function is async or sync just put it and you will be right.
Good luck!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice and simple. Just one advice: Why are you not using the ES6 async/await? Your "Step 2 and 3" can look like:
Good luck!
Thanks for your feedback. Honestly did not know how async-await worked, but did a bit of research and I edited the code to incorporate them.
A minor change from your suggestion, as .setCredentials() isn't async to my knowledge and I think userinfo.get() is. Feel free to correct me if I'm wrong.
Again thanks for your suggestion and will update the post accordingly.
I think it's ok. Async/Await is an amazing ES6 feature, keep going with that. You might forget about the callback hell.
And one more thing. Await can be used with the sync functions. It just does nothing if you make a mistake. E.g.
Of course, you don't have to put await anywhere, but if you don't know if the function is async or sync just put it and you will be right.
Good luck!