const dataToPost={ name:'Jenn', age: 40} axios.post("url", dataToPost) .then((response) => { console.log(response); // do something with the response }) .catch((error) => { if (error.response) { console.log(error.response); console.log("server responded"); } else if (error.request) { console.log("network error"); } else { console.log(error); } });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter