Skip to content

Instantly share code, notes, and snippets.

@georgeportillo
Last active November 21, 2016 03:59
Show Gist options
  • Save georgeportillo/569503edeb90941ac820c98a85315120 to your computer and use it in GitHub Desktop.
Save georgeportillo/569503edeb90941ac820c98a85315120 to your computer and use it in GitHub Desktop.
// I have this:
var data = `{
name: "foo"
}`;
apiWrapper.getCredentials(botId)
.then(function(credentials) {
apiWrapper.createIntent(credentials, data)
.then(intent => {
apiWrapper.getIntent(credentials, intent)
.then(intent => {
// ... I tried this but obviously it didn't work
apiWrapper.getCredentials(botId)
.then(apiWrapper.createIntent.(credentials, data))
.then(apiWrapper.getIntent(credentials, intent))
.then(intent => {
// I'm having a hard time putting these into a chain of then() functions.
// I'm getting stuck at passing data from a previous promise to the next one.
@mhchen
Copy link

mhchen commented Nov 21, 2016

apiWrapper.getCredentials(botId)
.then(credentials => {
  return apiWrapper.createIntent(credentials, data).then(intentData => {
    return apiWrapper.getIntent(credentials, intentData);
  }).then(intent => {
    // Do stuff with the actual intent object.
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment