Advertisement
edwinjackson

Untitled

Jun 27th, 2019
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const commonPostRequest = (data) => {
  2.     return fetch('https://jsonplaceholder.typicode.com/posts', {
  3.         method: 'POST',
  4.         headers: {
  5.             'Content-Type': 'application/json'
  6.         },
  7.         data: JSON.stringify(data)
  8.     }).then(response => {
  9.         return response.json();
  10.     })
  11. }
  12.  
  13. commonPostRequest({
  14.     title: 'foo',
  15.     body: 'bar',
  16.     userId: 1
  17. }).then(response => {
  18.     console.log(response);
  19. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement