I have already developed an app to fetch weather data from openweathermap.org. The app is built using redux and redux-saga. Now I have to redo it using "Unstated" instead of Redux for the state management.
The WeatherContainer.js class handles the state:
class WeatherContainer extends Container {
state = { weather: [] };
setWeatherData = (weather) => {
this.setState({ ...this.state, weather });
};
}
The axios request which gets the data from the API endpoing.
axios.get(process.env.REACT_APP_BASE_URL, {
params: {
id: cityIds,
units: "metric",
appid: process.env.REACT_APP_API_KEY,
},
});
I want to store the data received from axios inside the state.weather variable in WeatherContainer, which then can be used when I needed with .