Skip to content

Instantly share code, notes, and snippets.

@ankitsinghaniyaz
Created January 4, 2018 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitsinghaniyaz/35e16da58e970c6d7c58e4af7cc45da3 to your computer and use it in GitHub Desktop.
Save ankitsinghaniyaz/35e16da58e970c6d7c58e4af7cc45da3 to your computer and use it in GitHub Desktop.
A simple wrapper to handle CSRF in Rails and Vue
<template>
<div class="">
<input name="utf8" type="hidden" value="✓">
<input type="hidden" name="authenticity_token" :value="csrf">
</div>
</template>
<script>
export default {
data: function() {
return ({
csrf: document.querySelector('meta[name="csrf-token"]').getAttribute('content')
})
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment