I have a service that calls different providers of weather. I use a class to keep some data in common.
class Weather {
providerName = ''
constructor(providerName) {
this.providerName = providerName
}
class OpenWeather extends Weather {
getTodayTemperature: () => this.get('http://openweather.com/weatherToday.......')
}
class TomorrowWeather extends Weather {
getTodayTemperature: () => this.get('http://tommorow.io/weather.......')
}
The different APIs return data with different structures (normal) but all I want is to have way to format all getTodayTemperature function in all my child classes with the same structure.
Expected Result
{
morning: 26,
evening: 32
}
So for each return api i want to call a function
formatTemperature(morningNumber, eveningNumber)
Do you have a solution or another way to organize the code?
Thanks.