fetch('https://example.com/profile',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({'foo':'bar'}),}).then((res)=> res.json()).then((data)=>{// Do some stuff ...}).catch((err)=>console.log(err));
fetch('https://jsonplaceholder.typicode.com/posts',{method:'POST',headers:{'Content-Type':'application/json',},body:JSON.stringify({// your expected POST request payload goes heretitle:"My post title",body:"My post content."})}).then(res=> res.json()).then(data=>{// enter you logic when the fetch is successfulconsole.log(data)}).catch(error=>{// enter your logic for when there is an error (ex. error toast)console.log(error)})