react

Post Image

An Artisan’s Way of Data Fetching in React

In React applications, one of the most frequently executed tasks is to use the backend APIs and fetch data using fetch/axios/similar libraries and render it using the component. So, generally, the code has the following parts:React state to store the result of the API call as well as state to show the beautiful spinnerFunctional call to the API (most probably in useEffect)Statements in useEffect hook to update the state of the resultCatch statement to show errors related to API (alert...

Read