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(adapter-fetch): Correctly handle Request instance passed into fetch #259

Merged
merged 3 commits into from Sep 30, 2019

Conversation

@offirgolan
Copy link
Collaborator

commented Sep 26, 2019

Description

Correctly handle passing a Request instance to fetch.

fetch(new Request('/api/foo', { method: 'POST' }), { body: 'bar' });

Motivation and Context

Resolves #255.

The approach taken to solve for this is by patching the global Request class and storing the passed in url and options. This allows us to not only have direct access to the passed in body (e.g. no need to re-read it off the Request instance) but also not needing to hardcode which properties to take off the instance.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My code follows the code style of this project.
  • My commits and the title of this PR follow the Conventional Commits Specification.
  • I have read the contributing guidelines.
Copy link
Collaborator

left a comment

Looks good, just tests are failing in CI.

@offirgolan offirgolan marked this pull request as ready for review Sep 27, 2019
@offirgolan offirgolan changed the title feat(adapter-fetch): Correctly handle Request instance passed into fetch fix(adapter-fetch): Correctly handle Request instance passed into fetch Sep 27, 2019
@offirgolan offirgolan requested a review from jasonmit Sep 27, 2019
const { options } = pollyRequest.requestArguments;

const response = await this.native.apply(global, [
const response = await this.nativeFetch.apply(context, [

This comment has been minimized.

Copy link
@jasonmit

jasonmit Sep 27, 2019

Collaborator

Nice catch

Copy link
Collaborator

left a comment

:shipit:

@offirgolan offirgolan merged commit 593ecb9 into master Sep 30, 2019
2 of 4 checks passed
2 of 4 checks passed
continuous-integration/appveyor/branch AppVeyor build failed
Details
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@offirgolan offirgolan deleted the correctly-handle-request-instances branch Sep 30, 2019
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.