Skip to content

Commit

Permalink
fix: ignore not found locations [data]
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Stewart committed Jul 30, 2020
1 parent 718966d commit 6f7f07d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ async function * getCityData() {
const csdType =row['CSD type, english'];
if (!VALID_CSD_TYPES.includes(csdType)) continue;

const name = row['Geographic name, english'];
const province = row['Province / territory, english'];

yield {
name: row['Geographic name, english'],
province: row['Province / territory, english']
name,
province
};
}
}
Expand All @@ -49,6 +52,7 @@ async function getLocationData(value) {
url.searchParams.append('countrycodes', 'ca');

const req = await fetch(url.href);
if (req.status === 404) return null;
if (!req.ok) {
throw new Error(`Not ok: ${req.status}`);
}
Expand Down Expand Up @@ -77,6 +81,8 @@ async function * generateData() {
const value = [cityData.name, cityData.province].join(', ');

const location = await getLocationData(value);
if (!location) continue;

const timezone = await getTimezoneData(location);

yield [
Expand Down

0 comments on commit 6f7f07d

Please sign in to comment.