Created
January 4, 2018 13:29
-
-
Save ankitsinghaniyaz/35e16da58e970c6d7c58e4af7cc45da3 to your computer and use it in GitHub Desktop.
A simple wrapper to handle CSRF in Rails and Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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