-1

I request to server and get response as expected(I'm writing react app). In network tab (network tab screenshot) you see response is properly formatted to json. But when I console log answer with code below I see nothing:

fetch("http://192.168.20.81:8301/market/housing/home_price/", {
      method: "GET",
      mode: "no-cors",
      headers: {
        "Access-Control-Allow-Origin": "*"
      }
    })
      .then((res) => res.json())
      .then((data) => {
        console.log("Data: ", data);
      });

Also I get this error in console of firefox:

Uncaught (in promise) SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
Mahdi
  • 101
  • 7

1 Answers1

0

I think your data fetch from server which is json format. Please try it as below. I think it is ok

fetch("http://192.168.20.81:8301/market/housing/home_price/", {
      method: "GET",
      mode: "no-cors",
      headers: {
        "Access-Control-Allow-Origin": "*"
      }
    })
      .then((res) => {
      const data = res.data;
      console.log(data)
     }
     .catch((err) => console.log(err))
Phu Nguyen
  • 1
  • 1
  • 1