axios fix

Former-commit-id: 4e67b101d7613dc5a908a9710a298ab452e3a73e [formerly 4e67b101d7613dc5a908a9710a298ab452e3a73e [formerly 4e67b101d7613dc5a908a9710a298ab452e3a73e [formerly 4e67b101d7613dc5a908a9710a298ab452e3a73e [formerly e18674e079add9386877561fd5ff11e26d8a444d [formerly 9eea4ceea3d3b77eab71336bd5a35f3865865a7a]]]]]
Former-commit-id: 309a390168260b7182beb6cefb1d3fce25f41ad7
Former-commit-id: 2357580897c1c29d440ef3df6f59ccf8ecf6c898
Former-commit-id: 4dec8fba40d4f2d2c38e214281019b42cb937d0f [formerly d5986fb5b1d943e920a5e9f298bcfe2f39db84a6]
Former-commit-id: 2f5e3bf693e575217a377d633480e214609a257b
Former-commit-id: 67a233f1a96a698c8a303437bd350eef012f426a
Former-commit-id: 3529a8cb845e843a7971eaa2ae108e8c4abd7859
Former-commit-id: 75fdfbf8e6258c417b6f187dc4d5a4be1090aa56
Former-commit-id: b089d7b7d80123e876bf9b03d5bf9593fd79f780
This commit is contained in:
rongxingsun
2018-08-26 10:28:26 +08:00
parent d7f3a97f0c
commit 1f2d17a7ec
6 changed files with 28 additions and 16 deletions

View File

@@ -11,11 +11,13 @@ const service = axios.create({
// request interceptor
service.interceptors.request.use(
config => {
// Do something before request is sent
const token = util.cookies.get('token')
if (token && token !== 'undefined') {
// 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
config.headers['X-Token'] = token
if (!(/^https:\/\/|http:\/\//.test(config.url))) {
// Do something before request is sent
const token = util.cookies.get('token')
if (token && token !== 'undefined') {
// 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
config.headers['X-Token'] = token
}
}
return config
},