Thursday, 30 January 2020

Express js axios

hi when i try to send the result of my email send from my backend to the frontend i get the error "Access to XMLHttpRequest at 'http://maxcampbell.info/SendEmail' from origin 'http://www.maxcampbell.info' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request."​​​here's the code im using to call Axios"async SendEmail () {const response = await SendEmailService.register({email: this.email,message: this.message})console.log(response.data);axios.get('/StatusOfEmailSend').then(function (response) {if (response.data == "sucsess"){console.log("Sent email!");swal({title: "Email Sent",icon: "success",text: "your email has been sent",});}else {console.log("Error sending email!!!")swal({title: "Cannot send email",icon: "error",text: "your email has not been sent do to a server side error please try again",});}console.log(response);}).catch(function (error) {// handle errorconsole.log(error);}).then(function () {// always executed});}"

Submitted January 30, 2020 at 05:53PM by maxall41

No comments:

Post a Comment