chai-http
chai-http copied to clipboard
redirects(0) causes then() does not work
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
});
});