-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
res.body return a ReadableByteStream object on Chrome #11
Comments
@tarikjn if you submit a pull request I can take a look at reviewing and merging it. Right now we're really geared towards writing our own custom glue around the standard fetch API, otherwise might as well use the fetch API directly |
@niftylettuce I am confused, this is a bug report to say that Frisbee does not work on Chrome, not to suggest changes to the Frisbee API. Also the Frisbee API does not document how one is expected to use the response, so I have no idea if the response should be expected to be identical to a |
@tarikjn Ah! Okay, I can get tests for all the browsers in and figure out what the bug is there. The usage for the API is documented in the example. For instance, if you want to make a POST request and pass along in the body the param import Frisbee from 'frisbee';
const api = new Frisbee({
// ... options
});
makeRequest();
async function makeRequest() {
const res = await api.post('/', { body: { name: 'tarikjn' } });
// if the response was not 200 OK status code
// then an error will happen and we'll attempt to
// parse the body for the error response message,
// we'll look for `{ error: { message: 'some error msg' } }`
// and also just `{ message: 'some error message' }`
// in the response body
if (res.err) throw res.err;
console.log('response body', res.body);
console.log('response headers', res.headers);
} |
Alright, so it looks like the problem is that |
@tarikjn did you ever find a workaround or patch for this? I'd love to have a collaborator on Frisbee! |
I actually discussed this issue with @stayman last week. We came to the conclusion that the native fetch object should really be nested in the Frisbee response instead of merged, this would avoid this issue and potentially others, while avoiding confusion on native vs. lib API. @stayman suggested using Karma for browser testing. Unfortunately, none of us have time to contribute yet, and likely won't until next year, although we'd love to. Hopefully these suggestions in the meantime are helpful. |
@tarikjn if you can add a failing test I'll have a look at this when I'm free. |
I'm getting this error using react native in a saga right now. Specifically the part about Invalid JSON |
Just an update here - you can look at original response via As of v2.0.1 (about to be released in a few minutes) you can now pass |
Sorry I meant v2.0.2+*** |
Hi,
I am using the latest verison of Chrome on OS X (
Version 50.0.2661.102 (64-bit)
), withFrisbee
, andresponse.body
will returnReadableByteStream
instead of an expected response object as built by the result of parsing a json response.This seems to be the standard, but then why would the frisbee doc give this example? Trying to read the response with
response.json()
will return the following error:Uncaught (in promise) TypeError: Already read
.The text was updated successfully, but these errors were encountered: