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

fix: various quirks with how we handle accept headers #699

Merged
merged 3 commits into from
Aug 18, 2023

Conversation

erunion
Copy link
Member

@erunion erunion commented Aug 18, 2023

🚥 Resolves #697

🧰 Changes

  • If we have an accept header in a HAR, and that header is JSON-like, we'll now stop adding it to the code snippet. This'll help us avoid unnecessary bloat, like in the following snippet, because api understands and prioritizes JSON over anything else.
const sdk = require('api')('@basiq/v3.0#edsvz2rlk7p46u2');

sdk.auth('Basic someAuthToken');
sdk.postToken({scope: 'CLIENT_ACCESS'}, {accept: 'application/json', 'basiq-version': '3.0'})
  .then(({ data }) => console.log(data))
  .catch(err => console.error(err));
  • If someone does supply an accept header into a code snippet, like the above one, we'll now always send that as a proper header instead of it sometimes getting lumped in with the body payload.
  • Fixed a quirk where a header could also be duped and send as a header and in a body payload.

@erunion erunion added bug Something isn't working area:core Issues related to `core`, which is the package that powers the SDKs at runtime area:snippets Issues related to code snippets labels Aug 18, 2023
@erunion erunion marked this pull request as ready for review August 18, 2023 17:55
Copy link
Member

@domharrington domharrington left a comment

Choose a reason for hiding this comment

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

Lgtm!

Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

few minor questions below but otherwise LGTM

@erunion erunion merged commit e60c371 into main Aug 18, 2023
6 checks passed
@erunion erunion deleted the fix/header-quirks branch August 18, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core Issues related to `core`, which is the package that powers the SDKs at runtime area:snippets Issues related to code snippets bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to Generate Token using api Package due to Schema Mismatch
4 participants