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

Add option to include response headers in the result #744

Merged
merged 3 commits into from Oct 10, 2022

Conversation

adamjmcgrath
Copy link
Member

@adamjmcgrath adamjmcgrath commented Oct 7, 2022

Changes

Adding an option includeResponseHeaders to the Management Client so that you can get the response headers as well as the payload in the result of each method. eg

const mgmt = new ManagementClient();
const mgmt2 = new ManagementClient({ includeResponseHeaders: true });

const users = await mgmt.getUsers();
const { data: users, headers } = await mgmt2.getUsers();

mgmt.getUsers((err, users) => {
  console.log(users);
});
mgmt.getUsers((err, { data: users, headers }) => {
  console.log(users);
});

This is useful for users that want to use a different rate limit retry strategy than the exponential backoff on 429 used by this SDK (Like the one described here https://auth0.com/docs/troubleshoot/customer-support/operational-policies/rate-limit-policy#handle-rates-limitations-in-code)

References

fixes #742 #741

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds unit test coverage

Checklist

@adamjmcgrath adamjmcgrath added the review:medium Medium review label Oct 7, 2022
@adamjmcgrath adamjmcgrath requested a review from a team as a code owner October 7, 2022 14:48
callback = args.pop();
}
return new Promise((resolve, reject) => {
this.restClient[method](...args, (err, data, headers) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are always using the restClient (rest-facade)'s callback method because this is the only one that returns both the body of the response and the headers

@adamjmcgrath adamjmcgrath reopened this Oct 7, 2022
src/management/index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just added a missing period to the API docs.

@adamjmcgrath adamjmcgrath merged commit fa94fa1 into master Oct 10, 2022
@adamjmcgrath adamjmcgrath deleted the include-response-headers branch October 10, 2022 09:43
@adamjmcgrath adamjmcgrath mentioned this pull request Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:medium Medium review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retreive response headers
2 participants