不加token:
this.axios({
url: '/api/v1/cases?num=10',
method: 'GET'
}).then(res => {
console.log('res', res)
})
this.axios.get('/api/v1/cases?num=10').then(res => {
console.log('res', res)
})
请求头中携带token
headers: {
Authorization: 'Bearer ' + this.token 或者 headers: { token: this.token } 根据实际情况
}
get:
this.axios.get('/admin/api/v2/urole?permission_key=1', {
headers: { token: this.token }
}).then(res => {})
post:
this.axios.post('/admin/api/v2/adduser', {
user_name: this.user_key,
password: this.user_password,
role: JSON.stringify(lists)
}, { headers: { token: this.token } }).then(res => {})
put:
this.axios.put("/api/v1/refreshtoken", {}, {
headers: {
Authorization: 'Rearer ' + data
}
}).then(res => {}) 第一个参数可为空,第二个参数为请求头的token
this.axios.put('/admin/api/v2/adduser', {
password: this.newpassword,
key: this.editedItem.key,
role: JSON.stringify(arr)
}, { headers: { token: this.token } }).then(res => {})
delete:
this.axios.delete('/admin/api/v2/adduser?key=' + this.editedItem.key, {
headers: { token: this.token }
}).then(res => {})