Skip to content

Instantly share code, notes, and snippets.

@raphaelpor
Created November 7, 2016 00:11
Show Gist options
  • Save raphaelpor/ef7482441acd244c7a97ef0713f533dd to your computer and use it in GitHub Desktop.
Save raphaelpor/ef7482441acd244c7a97ef0713f533dd to your computer and use it in GitHub Desktop.
const config = {
method: 'POST',
body: JSON.stringify({ cat: 'grumpy' }),
cache: 'no-cache',
mode: 'no-cors',
}
fetch('http://localhost:8080/cats?categ=10&type=5', config)
.then(response => {
if(response.ok) {
return response.json();
}
})
.then(data => {
console.log(data);
})
.catch(err => {
console.log(err.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment