Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GET {url localhost } net::ERR_SSL_PROTOCOL_ERROR problem with my custom api

I develop an api with a partner. This one if you want to check..
https://github.com/korodum/TrainingAppBack

When I try to connect to this endpoint. I get this error.

ListTrainings.js:19
GET https://localhost:4000/trainings net::ERR_SSL_PROTOCOL_ERROR

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

The fetch is fine, as is the endpoint.

const [token] = useToken();
  const [ trainings, setTrainings] = useState();

  const [error, setError] = useState();
  const [success, setSuccess] = useState();
  const [loading, setLoading] = useState();
  
  const getTrainings = async () =>{

    try {
      
      setLoading(true);

      const res = await fetch('https://localhost:4000/trainings',{
        method:'GET',
        headers:{
          Authorization: token,
        }

      });
      console.log('RES', res);
      const body = res.json();

      if(body.status==='error') setError(body.message);
      else setTrainings(body.data.trainings);


    } catch (error) {
      console.error(error)
      setError(error.message)
    }finally{
      setLoading(false)
    }
  }

In postman….

enter image description here

>Solution :

You can’t get data through an insecure connection (http) from a secure connection (https)

Change the API Link like the following.

http://localhost:4000/trainings
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading