Created
December 16, 2016 17:13
-
-
Save brunojppb/7a1a4ae8c313ff980ccf9f444801b95e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fetch('/users', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content')}, | |
credentials: 'same-origin', | |
body: JSON.stringify( { id: 1, name: 'some user' } ) | |
}) | |
.then(function(data) { | |
console.log('request succeeded with JSON response', data) | |
}).catch(function(error) { | |
console.log('request failed', error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment