Comments (10)
@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
from frisbee.
@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 fetch
response.
from frisbee.
@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 name=tarikjn
:
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);
}
from frisbee.
Alright, so it looks like the problem is that .body
conflicts with fetch
browser implementations that support steams as they also use .body
for the stream.
from frisbee.
@tarikjn did you ever find a workaround or patch for this? I'd love to have a collaborator on Frisbee!
from 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.
from frisbee.
@tarikjn if you can add a failing test I'll have a look at this when I'm free.
from frisbee.
I'm getting this error using react native in a saga right now. Specifically the part about Invalid JSON
from frisbee.
Just an update here - you can look at original response via res.originalResponse
As of v2.0.1 (about to be released in a few minutes) you can now pass raw: true
to get raw fetch response so you can run your own methods on it, e.g. res.json()
or res.arrayBuffer()
from frisbee.
Sorry I meant v2.0.2+***
from frisbee.
Related Issues (20)
- Breaking changes in v3 HOT 2
- Could not find a declaration file for module Frisbee HOT 1
- How can i modify options in request interceptor? HOT 1
- Is there a way to pass `insecureHTTPParser` configuration to request? HOT 4
- `fetch-api` npm package name maintenance question
- http methods not available in jest tests HOT 1
- Rewrite codebase after removing xo rules that are turned off HOT 1
- Error / stack trace whenever API returns non-ok response HOT 2
- Retrying request after refreshing JWT access token in response interceptor HOT 7
- TypeScript definiton HOT 2
- .get() method strips trailing slash when GET params are passed in body HOT 2
- Feature: Follow redirects and add cookie support out of the box HOT 1
- Feature: Support GZIP/compression out of the box
- Feature: Timeout, Retry, and Queue HOT 11
- Feature: Hooks HOT 1
- Error: unsupported BodyInit type when attempting to post data to endpoint accepting the "application/x-www-form-urlencoded" content-type HOT 6
- How download a image with Frisbee?
- api.auth API should accept a function instead of static singleton string HOT 1
- Possible race conditions
- React Native use frisbee get api not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frisbee.