Skip to content

Instantly share code, notes, and snippets.

@bhimsur
Created July 21, 2020 13:46
Show Gist options
  • Save bhimsur/b75a304a3ac66f631d7f6d965241cfa2 to your computer and use it in GitHub Desktop.
Save bhimsur/b75a304a3ac66f631d7f6d965241cfa2 to your computer and use it in GitHub Desktop.
const data = { username: 'example' };
fetch('https://example.com/profile', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
.catch((error) => {
console.error('Error:', error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment