score:1

Accepted answer

your code looks correct, but you must make sure that the prediction you get in the response to your request is a number.

class app extends component {
  // ...

  fetchdata = () => {
    fetch("http://localhost:8000")
      .then(resp => resp.json())
      .then(data => {
        this.setstate({ prediction: number(data.prediction) });
      })
      .catch(error => {
        console.log(error, "catch the hoop");
      });
  };

  // ...
}

Related Query

More Query from same tag