Skip to content

Commit e246c09

Browse files
committed
If there’s dt query, no need retry
1 parent 332d00e commit e246c09

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

api/rainarea.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const shortenPercentage = (percentage) => +percentage.toFixed(2);
2626
const requestCache = new Map();
2727
const gotDefaultOptions = got.defaults.options;
2828

29-
const fetchRadar = (dt) =>
29+
const fetchRadar = (dt, opts) =>
3030
new Promise((resolve, reject) => {
3131
console.log(`Fetch: ${dt}`);
3232
const url = `http://www.weather.gov.sg/files/rainarea/50km/v2/dpsri_70km_${dt}0000dBR.dpsri.png`;
@@ -52,6 +52,7 @@ const fetchRadar = (dt) =>
5252
},
5353
],
5454
},
55+
...opts,
5556
})
5657
.then((response) => {
5758
console.timeEnd('Fetch radar');
@@ -219,7 +220,7 @@ module.exports = async (req, res) => {
219220
dt = +queryDt;
220221
output = cachedOutput[dt];
221222
if (!output) {
222-
const img = await fetchRadar(dt);
223+
const img = await fetchRadar(dt, { retry: 0 });
223224
const rainareas = convertImageToData(img);
224225
output = cachedOutput[dt] = {
225226
id: '' + dt,

0 commit comments

Comments
 (0)