0

I'm making a web application and configured a Django backend server to which I make API calls with axios.get. The problem is, the middleware code is being executed twice and I don't understand why, I'm using the API call within a React component's lifecycle method:

componentDidMount() {
    console.log('This line prints only once in the console');
    axios.get("http://server:port").
        .then((response) => {
            console.log('This line prints twice in the console!');
        })
        .catch((err) => console.log(err););
}

I was expecting the second call (in the dummy code snippet) to be executed only once...

Am I doing something wrong? What is going on?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

0 Answers0