Skip to content

Commit 60e6694

Browse files
committed
更改头部请求方式
1 parent 776599d commit 60e6694

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ window.axios = require('axios')
1010
window._ = require('lodash')
1111
window.Vue = Vue
1212
window.router = router
13-
//配置axios请求头部
14-
window.axios.defaults.headers.common = {
15-
'X-CSRF-TOKEN': window.config.csrfToken,
16-
'X-Requested-With': 'XMLHttpRequest'
17-
}
18-
window.axios.defaults.withCredentials=true
1913

2014
export default {
2115
start (){

src/store/actions.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ export const MessageInfo = (message, data) => {
1515
}
1616
/* 公共post请求方法 */
1717
export const getData = ({ commit,state },{apiUrl = state.apiUrl, postData = null, thenFunction = null, catchFunction = null, message = null}) => {
18-
window.axios.post(apiUrl,postData,{withCredentials:true})
18+
let token_type = localStorage.getItem('token_type')
19+
let access_token = localStorage.getItem('access_token')
20+
let refresh_token = localStorage.getItem('refresh_token')
21+
window.axios.post(apiUrl,postData,{
22+
withCredentials:true,
23+
headers: {
24+
'Accept': 'application/json',
25+
'Authorization': token_type + ' ' + access_token
26+
},
27+
})
1928
.then((Response) => {
2029
if (thenFunction) {
2130
thenFunction(Response)

0 commit comments

Comments
 (0)