Open mauron85 opened 10 years ago
This is still an issue. I was trying the same exact thing.
If you use ES6 you can use a Proxy (I actually haven't tested it with headers, but should work):
"use strict";
class Header {
get Authorization() {
return this._auth;
}
set Authorization(value) {
this._auth = value;
}
}
const hd = new Header();
request
.post('/token')
.auth({user: user.username + '#' + user.company, pass: user.password})
.json(true)
.end(function(err, res) {
if (err) {
return done(err);
}
hd.Authorization = 'Bearer ' + res.body.access_token;
})
.post('/users')
.headers(hd)
.json(users)
.end(function(err, res) {
done();
});
Passing argument from one request response to another request is currently not possible
Expected behavior is to pass token from first response to next post request: Actual behavior is token is undefined.
The current workaround is to use then: