Giter Site home page Giter Site logo

Comments (2)

Drakeoon avatar Drakeoon commented on June 20, 2024 1

Got the same problem recently. In my case adding double await helped for some reason:

#  before
const userDetails = await client.get(`users/${id}`).json();

#  after
const userDetails = await (await client.get(`users/${id}`)).json();

Really don't know why that helps, but after this change I've never experienced any problems. I'm also using [email protected] (as mentioned above by @vibl) and [email protected]

from ky.

vibl avatar vibl commented on June 20, 2024

I have this problem too. About 1 in 6 requests returns an empty response body in Bun (no problem in Node.js).

If I add the following line in the function_() function (line 19), I always get a response body with the cloned request, even when the main request response doesn't return a body.

        let response = await ky._fetch();
        // This prints an empty body in about 1 in 6 requests
         response.clone().blob().then(blob => blob.text()).then( str => console.log("Blob for main request:", str));
        // This always prints a body
        fetch(this.request.clone(), {}).then( res => res.blob()).then(blob => blob.text()).then( str => console.log("Blob for cloned request:", str));
       

from ky.

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.