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

@offirgolan offirgolan 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.

@offirgolan offirgolan requested a review from jasonmit September 26, 2019 21:51
@offirgolan offirgolan added 📦 adapter-fetch bug 🐞 Something isn't working labels Sep 26, 2019
Copy link
Contributor

@jasonmit jasonmit left a comment

Choose a reason for hiding this comment

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

Looks good, just tests are failing in CI.

@offirgolan offirgolan marked this pull request as ready for review September 27, 2019 17:29
@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 September 27, 2019 17:38
const { options } = pollyRequest.requestArguments;

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

Choose a reason for hiding this comment

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

Nice catch

Copy link
Contributor

@jasonmit jasonmit left a comment

Choose a reason for hiding this comment

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

:shipit:

@offirgolan offirgolan merged commit 593ecb9 into master Sep 30, 2019
@offirgolan offirgolan deleted the correctly-handle-request-instances branch September 30, 2019 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working 📦 adapter-fetch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Fetch Adapter support for Request objects is incomplete
2 participants