1async function postData(){
2
3const url = 'https://jsonplaceholder.typicode.com/posts'
4
5let data = {
6 title: 'Saga of async/await',
7 body: 'Directed by GrimReaper',
8 userId: 7,
9 }
10
11const param = {
12
13method : 'Post' ,
14
15headers : {
16
17"content-type" : "application/json;charset = UTF-8"
18
19},
20
21body : JSON.stringify(data)
22
23}
24
25
26const sendRequest = await fetch(url , param)
27
28const response = await sendRequest.json()
29
30return response
31
32
33}
34
35postData().then((data)=>{
36
37console.log(data)
38
39})