My front-end is not communicating with the Back-End

Asked

Viewed 62 times

0

I created a simple form in React to communicate with the back-end (Node js), but when I click the form button (this button has an event that is responsible for performing the request to the back-end gives the following message: "Failed to load Resource: net::ERR_SSL_PROTOCOL_ERROR"

onClick = (event) => {
  httRequest.open('GET', 'https://localhost:5000', true);

  httRequest.onreadystatechange = function() {
    if ( httRequest.readyState === 4 ){
      if ( httRequest.status === 200 ) 
        console.log(httRequest.responseText)
      else
        console.log('Some error in httRequest.readyState == 200')
    } else
      console.log('Error in the if == 4')
  }
  httRequest.send();
}

Basically, when called the event, he should request the address quoted. But every time I select the button it drops in the condition below:

console.log('Some error in httRequest.readyState == 200')
  • Alberto, you are using local https?

  • No, I’m using http, but I think I’ve solved the problem. I have to use CORS in the other application next to express.

  • It worked, now I have to send the information from Form (front-end) to the second application (back-end) create in the database.

  • You will probably have problems with localhost when you use https protocol, because on the local machine you need to free up the local address on your browser link, do so first before making a request call...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.