17 lines
338 B
JavaScript
17 lines
338 B
JavaScript
|
import axios from "axios";
|
||
|
|
||
|
async function postData(url, body = {}) {
|
||
|
|
||
|
let response;
|
||
|
|
||
|
try {
|
||
|
response = await axios.post(url, body);
|
||
|
console.log(response.data); // handle successful response
|
||
|
} catch (error) {
|
||
|
console.error(error); // handle error
|
||
|
}
|
||
|
|
||
|
return response
|
||
|
}
|
||
|
|
||
|
module.exports = postData
|