Conversation
jsdelfino
left a comment
There was a problem hiding this comment.
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.
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.
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.
Suggesting to convert to async/await here as well.
src/app.js
Outdated
| console.log('Error sending message:', err); | ||
| }); | ||
|
|
||
| }); No newline at end of file |
There was a problem hiding this comment.
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.