Skip to content

Conversation

@kevingrozav
Copy link

Hi Sebastian,

Yay, my first pull request! I "promisified" the api helper functions and converted main function to use async/await.

fingers crossed.

Copy link
Contributor

@jsdelfino jsdelfino left a 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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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
console.log('Error sending message:', err);
});

});
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants