1//The finally() method can be useful if you want to do some processing or cleanup once the promise is settled, regardless of its outcome.
2
3//So if you want to setloading to false regardless of error or success, do this
4
5axios
6 .get('/products', { params: params })
7 .then((response) => {
8 if (isMountedRef.current) {
9 setProducts(response.data.data);
10 setMeta(response.data.meta);
11 }
12 })
13 .finally(() => {
14 setLoading(false);
15 });