Skip to content Skip to sidebar Skip to footer

Axios.get() ReactJS

I'm making simple To-Do App in ReactJS.For now I'm adding Routes I managed to implement .post method,but now I'm stuck on .get Method,it's being looped and is rendering over and ov

Solution 1:

The reason for you the above code is causing a problem because here in the above code we are not using react-life cycle hooks properly and making HTTP calls in the render function. As this is the class-based component. You could try using componentDidMount() life cycle hook to make all the HTTP calls before the components load and componentUpdateMount() lifecycle hook after it updates.

If in case you are using functional components in react than in react 16 and above versions we now have react-hooks, these react hooks help us to make the same HTTP in useEffect() hook. You could read about it further from the react official website as well. I hope it will help :) https://reactjs.org/docs/react-component.html

https://reactjs.org/docs/hooks-effect.html


Post a Comment for "Axios.get() ReactJS"