vue.js - 在 Vue js 中发布时缺少 csrf 令牌
问题描述
在调用 post 时说缺少 csrf 令牌。我使用了 Vuejs &drf 我将如何在 Vue 中传递 csrf 令牌
function(){
this.loading = true;
this.$http.post('/get_books/', this.new_book).then(response=>
{this.getBooks();})
解决方案
您可以使用全局配置设置 csrf 令牌
Vue.http.headers.common['X-CSRF-TOKEN'] = csrfToken