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

Response extends body #92

Merged
merged 7 commits into from
Dec 4, 2018
Merged

Response extends body #92

merged 7 commits into from
Dec 4, 2018

Conversation

zackargyle
Copy link
Owner

Making Response extend Body and using its resolver methods. The only backwards incompatible change is throwing for unsupported response types.

@zackargyle
Copy link
Owner Author

@sodabrew Would this work for your use case?

@sodabrew
Copy link

sodabrew commented Dec 3, 2018

I'll test this tomorrow and let you know!

@sodabrew
Copy link

sodabrew commented Dec 4, 2018

Close! I made this edit locally, as _text is not defined:

diff --git a/packages/service-worker-mock/models/Body.js b/packages/service-worker-mock/models/Body.js
index 0514d1b..c0858e1 100644
--- a/packages/service-worker-mock/models/Body.js
+++ b/packages/service-worker-mock/models/Body.js
@@ -18,11 +18,11 @@ class Body {
   }

   json() {
-    return this.resolve('json', body => JSON.parse(body._text));
+    return this.resolve('json', body => JSON.parse(body.text));
   }

   text() {
-    return this.resolve('text', body => body._text);
+    return this.resolve('text', body => body.text);
   }

   resolve(name, resolver) {

}

json() {
this.resolve('json', body => JSON.parse(body._text));
return this.resolve('json', body => JSON.parse(body._text));
Copy link

Choose a reason for hiding this comment

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

I see that _text wasn't changed in this PR, but I couldn't find where it was defined previously?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah that was an existing bug! Surprised it's never come up. Fixed.

@zackargyle zackargyle merged commit 817efcb into master Dec 4, 2018
@zackargyle zackargyle deleted the response-extends-body branch December 4, 2018 17:37
@zackargyle
Copy link
Owner Author

@sodabrew This is published and available on npm as v1.10.2

@sodabrew
Copy link

sodabrew commented Dec 4, 2018

🥇 thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants