Skip to content

Instantly share code, notes, and snippets.

Last active May 21, 2020 12:23
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
postRequest('', {user: 'Dan'})
.then(data => console.log(data)) // Result from the `response.json()` call
function postRequest(url, data) {
return fetch(url, {
credentials: 'same-origin', // 'include', default: 'omit'
method: 'POST', // 'GET', 'PUT', 'DELETE', etc.
body: JSON.stringify(data), // Use correct payload (matching 'Content-Type')
headers: { 'Content-Type': 'application/json' },
.then(response => response.json())
.catch(error => console.error(error))
Copy link

سلام به همگی

Copy link

من محمد برزگر هستم از ساری
حال شما خوب هست دوست من

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment