I would like to know how to display a toastr alert when clicking the "send information" button showing "Your information has been sent" and if it fails "Your information could not been sent, here is a problem!"
the code i have for sending is:
const sendMail = async (data: FormData) => {
const response = await fetch('https://us-central1-my-website.cloudfunctions.net/apply-function', {
method: 'POST',
body: data,
});
};
Once resolved or rejected, the
response
object will have a property calledstatus
which indicates whether the request was resolved or rejected by the server (API). You can use thestatus
property to show alerts accordingly.Example