0
const getProducts = async ()=>{
        try {
          const res = await axios.get("http://localhost:5000/api/products")
          console.log(res)
        } catch (error) {
          console.log(error)
        }
      }

this is my code in console its showing "AxiosError code: "ERR_NETWORK" " etc....

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Goutham
  • 1
  • 1
  • 3
  • 2
    ERR_NETWORK means it is not able to connect to your server. Kindly make sure your local server is running and also check if the port is correct. – Yehya May 25 '22 at 09:41
  • @Yehya I rechecked server is live and port number is same but still returning "ERR_NETWORK" – Goutham May 25 '22 at 10:23
  • 1
    did you try making the Get request to server using Postman? what does it return? – Yehya May 25 '22 at 10:25
  • @Yehya yeah I tried its working. Its returning the data – Goutham May 25 '22 at 10:40
  • This stackoverflow comment might be helpful: https://stackoverflow.com/questions/45980173/react-axios-network-error#comment78919641_45980173 If you try doing a `console.log(error.response.data)` and posting the full error message output someone will be able to catch it. – Alex Mapley May 25 '22 at 22:37
  • @AlexMapley I tried its showing data : `undefined` btw I am using it with react – Goutham May 26 '22 at 05:45

0 Answers0