-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update functions to Async/Await #2
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this pull request. Looks like a good start! I have a few review comments.
src/app.js
Outdated
id | ||
// Return a list of spaces the app belongs to | ||
const spaces = (tok) => { | ||
return new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to convert this to use the async keyword (vs explicitly returning a Promise) and convert the asynchronous calls inside this function to use await (as this pull request seems to be about converting the sample async/await), instead of having a mix of async/await and promise programming models.
src/app.js
Outdated
'https://api.watsonwork.ibm.com/v1/spaces/' + spaceId + '/messages', { | ||
headers: { | ||
Authorization: 'Bearer ' + tok | ||
const token = (appId, secret) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above, suggesting to convert to async/await as well.
src/app.js
Outdated
}; | ||
|
||
|
||
// Send an app message to the conversation in a space | ||
const send = (spaceId, text, tok) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting to convert to async/await here as well.
src/app.js
Outdated
@@ -149,5 +139,4 @@ if(require.main === module) | |||
(err) => { | |||
if(err) | |||
console.log('Error sending message:', err); | |||
}); | |||
|
|||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what that last character at the bottom of the file is.
Description: Promisify post from request module, Convert callback style functions to implement async/await Remove done flag from unit test and check function Make unit test async/await
Hi Sebastian,
Yay, my first pull request! I "promisified" the api helper functions and converted main function to use async/await.
fingers crossed.