vue本地环境接收api数据

axios.post('/api/news/get?channel=头条&start=0&num=10&appkey=02961c4ddeeb7265').then(function(data){
console.log(data);
},function(err){
console.log(err);
})
装api
获取令牌:
let date={
"grant_type": "client_credentials",
"client_id": "game-client",
"client_secret": "0a0e2b7c0f223ff235810cbdc70f1d97",
"scope": "game_client"
};
axios.post('/zhuang/token',date).then(function(data){
console.log(data.data.data.access_token);
},function(err){
console.log(err);
})
登录:
let date={
"grant_type": "password",
"client_id": "game-client",
"client_secret": "0a0e2b7c0f223ff235810cbdc70f1d97",
"scope": "game_client",
"username": "18814137313",
"password": "123456"
};
axios({
method: 'post',
url: '/zhuang/token',
data: date,
headers: {Authorization:"Bearer "+'32l78QHdk3wieAcVpYhzO4LhHaokPYdBi4znKuCa1v'}
}).then(function(data){
console.log(data);
});
获取用户信息
axios({
method: 'get',
url: '/zhuang/users/me',
headers: {Authorization:"Bearer "+'ZSfXReFAswcbxPWGqXfVOUlVGJUXxqoISoyfXI2z',token:'47uabccl3Acc9DEBPwF7w4WRdhAhj5kwIfMeJqeR'}
}).then(function(data){
console.log(data);
});

浙公网安备 33010602011771号