在该代码中如何加入token参数,使得能成功获取json。fetch("http://localhost:8000/api/calendar").then(res => res.json()).then(res => {this.arr = res})
时间: 2023-04-07 08:01:10 浏览: 201
你可以在fetch请求中添加一个headers对象,包含Authorization字段和对应的token值,如下所示:
fetch("http://localhost:8000/api/calendar", {
headers: {
Authorization: "Bearer your_token_here"
}
})
.then(res => res.json())
.then(res => {this.arr = res})
阅读全文
相关推荐


















