如何将令牌发送到标头?
我的代码:
getCategoryList = () => {
return axios.get(`${this._api}/groups/list`, {
headers: {"X-CSRF-TOKEN": `Bearer ${this._token}`},
});
};
答案 0 :(得分:0)
这是从您的后端来的吗?如果是的话,如果您使用Node.js并使用此代码,请尝试使用npm install cors
安装cors模块
const express = require("express");
const cors = require("cors");
const app = express();
app.use(cors());
或者如果您使用deno,则可以尝试
import { oakCors } from "https://deno.land/x/cors/mod.ts";
import { Application } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
app.use(oakCors());