0

I have my react project files on hosting, complete and run node.js server on remote desktop

now i try to send some request and catch errors all time.

If i use this php code for test connect to server, everything is ok.

<?php
$url = 'http://000.00.000.00/test';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo "err: " . $error;
} else {
echo "Resp: " . $response;
}
curl_close($ch);
?>

but this doesn't work(

  import React from 'react';
  import axios from 'axios';
  function App() {
  axios.get('http://000.00.00.00/test')
  .then(response => {
  console.log(response.data); 
  })
  .catch(error => {
   console.error(error); 
  });

How i can do this with my React project?

i try this :

https://www.codewithyou.com/blog/how-to-use-axios-to-handle-ssltls-certificate-verification-errors-in-nodejs

SSL certificate - disable verification in axios and react

0 Answers0