Skip to content

Instantly share code, notes, and snippets.

@laniltee
Created October 26, 2018 15:28
Show Gist options
  • Save laniltee/afaeae229b434084678b8cbcab1e9d25 to your computer and use it in GitHub Desktop.
Save laniltee/afaeae229b434084678b8cbcab1e9d25 to your computer and use it in GitHub Desktop.
get token
<script>
function getTokenAndInject() {
$("#errorMessage").hide();
axios.post('/tokens', {withCredentials: true})
.then(response => {
$("#contentForm").append(
`<input type="text" hidden name="inputToken" id="inputToken" value=${response.data.token} />`
)
})
.catch(error => {
$("#errorMessage").show();
window.location.href = '/';
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment