mikeal / bent

Functional JS HTTP client (Node.js & Fetch) w/ async await
2.2k stars 106 forks source link

Error response body is a still promise #108

Open FrankMartinezSRC opened 4 years ago

FrankMartinezSRC commented 4 years ago

It seems the issue #81, and #91 by extension, is still happening.

Code to reproduce:

const bent = require('bent');

(async () ={
    try {
        await bent('POST', 'json', `https://google.com`)();
    } catch (err) {
        console.error(err);
    }
})();

Outputs:

Promise { pending }
Templum commented 4 years ago

I can confirm that responseBody is a Pending Promise. However, it is possible to get the body using .json(). But this causes responseBody to show up as Error: body stream is locked when observed via Debugger.

seanthingee commented 2 years ago

Same here, responseBody is a pending promise in the Browser when the statusCode is 400. I'm using 7.3.12.