/vue-csrf

A Vue.js plugin for getting CSRF-token

Primary LanguageJavaScriptMIT LicenseMIT

vue-csrf

A Vue.js plugin for getting CSRF-token

Installation

yarn add vue-csrf

or

npm install vue-csrf --save

Usage

Import package

import VueCsrf from 'vue-csrf';

Vue.use(VueCsrf);

or with options

import VueCsrf from 'vue-csrf';

Vue.use(VueCsrf, {
    selector: 'meta[name="csrf-token"]', // selector of csrf element with csrf-token value
    attribute: 'content', //attribute of csrf-token element
});

then you can get csrf-token by next commands

this.$csrfToken;
Vue.csrfToken;

this.$csrf.get();
Vue.csrf.get();

Resetting value

Also you can set new value by

this.$csrf.set('new_csrf');
Vue.csrf.set('new_csrf');