complete up to request for storing azmayesh_sample and complete design of...
This commit is contained in:
@@ -11,18 +11,18 @@ const useProvinces = () => {
|
||||
useEffect(() => {
|
||||
const fetchCities = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_PROVINCE_LISTS}`); // Fetch the cities from the API
|
||||
setProvinces(response.data.data); // Set the cities data
|
||||
setLoadingProvinces(false); // Set loading to false after successful fetch
|
||||
const response = await requestServer(`${GET_PROVINCE_LISTS}`);
|
||||
setProvinces(response.data.data);
|
||||
setLoadingProvinces(false);
|
||||
} catch (e) {
|
||||
console.error("Error fetching cities:", e);
|
||||
console.error("Error fetching provinces:", e);
|
||||
setErrorProvinces(e);
|
||||
setLoadingProvinces(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCities(); // Call the fetch function
|
||||
}, []); // Empty dependency array to ensure it only runs once
|
||||
fetchCities();
|
||||
}, []);
|
||||
|
||||
return { provinces, loadingProvinces, errorProvinces };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user