📜  axios 中的授权令牌 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:03.861000             🧑  作者: Mango

代码示例1
const api = 'your api'; 
const token = JSON.parse(sessionStorage.getItem('data'));
const token = user.data.id; /*take only token and save in token variable*/
axios.get(api , { headers: {"Authorization" : `Bearer ${token}`} })
.then(res => {
console.log(res.data);
.catch((error) => {
  console.log(error)
});