Skip to content

Commit

Permalink
Added error handling in case free-api quota is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanamisra committed Dec 31, 2024
1 parent 4352171 commit 875e93b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
41 changes: 33 additions & 8 deletions src/components/HeatWavePredictor/HeatWavePredictor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,42 @@ const HeatWavePredictor = () => {
setElevation(new_elevation);
displayHeatwaveReport(max_temp, new_elevation);
})
.catch(error => {
// MOCK DATA FOR DEV
alert("Unfortunately OpenWeather's API has reached its usage quota for the month. Mock weather data will be displayed to demonstrate the tool functionality. Other calculations remain as fair as ever!")
const lat = 28.6517178;
const long = 77.2219388;
const max_temp = 15;
const new_elevation = 226;
setMaxTemp(max_temp);
setElevation(new_elevation);
displayHeatwaveReport(max_temp, new_elevation);
});
})
.catch(error => {
// MOCK DATA FOR DEV
alert("Unfortunately OpenWeather's API has reached its usage quota for the month. Mock weather data will be displayed to demonstrate the tool functionality. Other calculations remain as fair as ever!")
const lat = 28.6517178;
const long = 77.2219388;
const max_temp = 15;
const new_elevation = 226;
setMaxTemp(max_temp);
setElevation(new_elevation);
displayHeatwaveReport(max_temp, new_elevation);
});
})
.catch(error => {
// MOCK DATA FOR DEV
alert("Unfortunately OpenWeather's API has reached its usage quota for the month. Mock weather data will be displayed to demonstrate the tool functionality. Other calculations remain as fair as ever!")
const lat = 28.6517178;
const long = 77.2219388;
const max_temp = 15;
const new_elevation = 226;
setMaxTemp(max_temp);
setElevation(new_elevation);
displayHeatwaveReport(max_temp, new_elevation);
});
setSubmitted(true);
// MOCK DATA FOR DEV
// const lat = 28.6517178;
// const long = 77.2219388;
// const max_temp = 15;
// const new_elevation = 226;
// setMaxTemp(max_temp);
// setElevation(new_elevation);
// displayHeatwaveReport(max_temp, new_elevation);
}

const displayHeatwaveReport = (max_temp, elevation) => {
Expand Down
14 changes: 14 additions & 0 deletions src/components/StormPredictorTool/StormPredictor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,21 @@ const StormPredictor = () => {
newStorm = "Super Cyclone";

setStorm(newStorm);
})
.catch(error => {
// MOCK DATA FOR DEV
alert("Unfortunately OpenWeather's API has reached its usage quota for the month. Mock weather data will be displayed to demonstrate the tool functionality. Other calculations remain as fair as ever!")
const newWindSpeed = 999.999;
setWindSpeed(newWindSpeed);
setStorm("Cyclonic Storm")
});
})
.catch(error => {
// MOCK DATA FOR DEV
alert("Unfortunately OpenWeather's API has reached its usage quota for the month. Mock weather data will be displayed to demonstrate the tool functionality. Other calculations remain as fair as ever!")
const newWindSpeed = 999.999;
setWindSpeed(newWindSpeed);
setStorm("Cyclonic Storm")
});
setSubmitted(true);
};
Expand Down

0 comments on commit 875e93b

Please sign in to comment.