how to make a post request using async
async function postData(){
const url = 'https://jsonplaceholder.typicode.com/posts'
let data = {
title: 'Saga of async/await',
body: 'Directed by GrimReaper',
userId: 7,
}
const param = {
method : 'Post' ,
headers : {
"content-type" : "application/json;charset = UTF-8"
},
body : JSON.stringify(data)
}
const sendRequest = await fetch(url , param)
const response = await sendRequest.json()
return response
}
postData().then((data)=>{
console.log(data)
})