I am testing this React Rest service code. When I open the page, I see it's making two calls to REST server.
Code to call the server API
export const App = (): React.FC<user[]> => {
const [user, setUser] = useState<user | undefined>();
useEffect(() => {
fetch('https://jsonplaceholder.typicode.com/users')
.then((response) => response.json())
.then((json) => setUser(json));
}, []);
Here is the full article: https://cynoteck.com/blog-post/how-to-call-web-api-with-useeffect-hook-in-react-typescript/#What_is_a_RESTful_API
I also tested this with my local machine REST
service, it's making two calls.
May I know how to prevent this duplicate request?