Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const commonPostRequest = (data) => {
- return fetch('https://jsonplaceholder.typicode.com/posts', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- data: JSON.stringify(data)
- }).then(response => {
- return response.json();
- })
- }
- commonPostRequest({
- title: 'foo',
- body: 'bar',
- userId: 1
- }).then(response => {
- console.log(response);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement