在 Vue.js 项目中,我怎样才能获得csrftoken
?
我试过使用js-cookie
,但无法得到它:
import Cookies from 'js-cookie';
if (Cookies.get('csrftoken')!==undefined) { // there will skip, because the Cookies.get('csrftoken') is undefined.
config.headers['x-csrftoken']= Cookies.get('csrftoken'); // 'CSRFToken '
}
但我可以得到其他饼干。
编辑
Cookies.get('csrftoken')
这段代码得到undefined
。
但是当我访问时,有csrftoken
.