I\'m working on a project that requires me to make requests to an API. What is the proper form for making a POST request with Async/Await?
As an example, here is my
Here is an example with configuration:
try {
const config = {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(data)
}
const response = await fetch(url, config)
//const json = await response.json()
if (response.ok) {
//return json
return response
} else {
//
}
} catch (error) {
//
}