Skip to content

Instantly share code, notes, and snippets.

@nxvhm
Created June 9, 2020 11:16
Show Gist options
  • Save nxvhm/e5923c5c4dba0fa67b91322dd2fdbeaf to your computer and use it in GitHub Desktop.
Save nxvhm/e5923c5c4dba0fa67b91322dd2fdbeaf to your computer and use it in GitHub Desktop.
POST request with fetch
fetch('http://mydomain.local/api/photo', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({'lat': 12121, lng: 1212121, title: 'dasdasdsa', 'image': 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=='})
}).then(res => {
console.log('res', res);
}).catch(err => {
console.log('err', err);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment