chai-http icon indicating copy to clipboard operation
chai-http copied to clipboard

redirects(0) causes then() does not work

Open mkatsoho opened this issue 9 years ago • 1 comments

if using redirects(5), .then() works well for a POST. But if using redirect(0), which I only want to get the first http req's response, .then() never run. The workaround is using .end(err, res) instead.

Can you help to fix this?

My original code:

agent.post('/login')
    .field("pwd", pwd)
    .field("user", uid)
    .then( function( res ) { 
        debug(res, 'POST login');
        expect(res).to.have.status(200);

    agent.get( res.body.location )   // get the location field from the json response body
        .redirects(0)
        .then( function( res ) { 
            console.log('==================');    // this is never printed out
        });
 });

mkatsoho avatar Dec 16 '15 03:12 mkatsoho

I think this is related to this superagent issue.

Another candidate for dropping superagent.

austince avatar May 27 '19 18:05 austince