Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- axios.interceptors.request.use((req) => {
- req.headers.authorization = `Bearer: ${MYTOKEN}`;
- return req;
- });
- const router = express.Router();
- router.use(function timeLog(req, res, next) {
- console.log(req.headers.authorization); // undefined :(
- })
- { host: 'localhost:5000',
- connection: 'keep-alive',
- 'access-control-request-method': 'POST',
- origin: 'http://localhost:8080',
- 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
- 'access-control-request-headers': 'authorization,content-type',
- accept: '*/*',
- 'accept-encoding': 'gzip, deflate, br',
- 'accept-language': 'fr-FR,fr;q=0.9,en;q=0.8,en-US;q=0.7,ru;q=0.6'
- }
- router.use(function timeLog(req, res, next) {
- console.log(req.headers.authorization); // of course this is will undefined
- })
- import axios from 'axios'
- axios.interceptors.request.use((req) => {
- req.headers.authorization = `Bearer: ${MYTOKEN}`;
- return req;
- });
- router.use(function timeLog(req, res, next) {
- console.log(axios.headers.authorization); // here we are
- })
Add Comment
Please, Sign In to add comment