Created
November 14, 2018 18:05
-
-
Save hpjaj/9b6b923b42017c094f07c6982fd72a0a to your computer and use it in GitHub Desktop.
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
// app/javascript/util/helpers.js | |
function csrfToken(document) { | |
return document.querySelector('[name="csrf-token"]').content; | |
} | |
export function passCsrfToken(document, axios) { | |
axios.defaults.headers.common['X-CSRF-TOKEN'] = csrfToken(document); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment