Giter VIP home page Giter VIP logo

Comments (10)

niftylettuce avatar niftylettuce commented on September 15, 2024

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

tarikjn avatar tarikjn commented on September 15, 2024

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

niftylettuce avatar niftylettuce commented on September 15, 2024

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

tarikjn avatar tarikjn commented on September 15, 2024

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.

niftylettuce avatar niftylettuce commented on September 15, 2024

@tarikjn did you ever find a workaround or patch for this? I'd love to have a collaborator on Frisbee!

from frisbee.

tarikjn avatar tarikjn commented on September 15, 2024

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.

OmgImAlexis avatar OmgImAlexis commented on September 15, 2024

@tarikjn if you can add a failing test I'll have a look at this when I'm free.

from frisbee.

fourcolors avatar fourcolors commented on September 15, 2024

I'm getting this error using react native in a saga right now. Specifically the part about Invalid JSON

from frisbee.

niftylettuce avatar niftylettuce commented on September 15, 2024

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.

niftylettuce avatar niftylettuce commented on September 15, 2024

Sorry I meant v2.0.2+***

from frisbee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.