I have a very basic api and all it does is return the text "Sunny day".
I create a react project using create react app and try to call the api once then printing result to the console.
Here is the react app
import logo from './logo.svg';
import './App.css';
function App() {
fetch('https://localhost:44386/weatherforecast')
.then(response => response.text())
.then(data => console.log(data));
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
The problem is the api is getting called twice on page load
Can anybody explain why?