Skip to content
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

return result from callback #106

Merged
merged 1 commit into from Sep 21, 2015

Conversation

@theverything
Copy link
Contributor

commented Sep 2, 2015

Returning the result of the callback allows you to chain the promise like you would expect.

function getUserAccount() {
  return axios.get('/user/12345');
}

function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}

axios.all([getUserAccount(), getUserPermissions()])
  .then(axios.spread(function (acct, perms) {
    return doSomethingWithAccount(acct);
  }))
  .then(function (result) {
    // do stuff with result
  });
return result from callback
returning the result of the callback allows you to chain the promise
like you would expect

mzabriskie added a commit that referenced this pull request Sep 21, 2015

@mzabriskie mzabriskie merged commit 68867fb into axios:master Sep 21, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.09%) to 84.648%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.