Fixed a bug where req isn't terminated with coords error
This commit is contained in:
4
index.js
4
index.js
@@ -45,7 +45,7 @@ app.use('/rep', async (req, res) => {
|
|||||||
const closestCity = await (await fetch(
|
const closestCity = await (await fetch(
|
||||||
`https://geo.api.gouv.fr/communes?lat=${lat}&lon=${lon}`
|
`https://geo.api.gouv.fr/communes?lat=${lat}&lon=${lon}`
|
||||||
)).json();
|
)).json();
|
||||||
let codeDepartement = String(closestCity[0].codeDepartement)
|
let codeDepartement = closestCity[0]?.codeDepartement
|
||||||
|
|
||||||
// If somehow, the gov api can't find the nearest city...
|
// If somehow, the gov api can't find the nearest city...
|
||||||
if (!codeDepartement || codeDepartement === "") {
|
if (!codeDepartement || codeDepartement === "") {
|
||||||
@@ -56,7 +56,7 @@ app.use('/rep', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Changes dep code to format of filenames on server, ie "075"
|
// Changes dep code to format of filenames on server, ie "075"
|
||||||
codeDepartement = codeDepartement.padStart(3, "0");
|
codeDepartement = String(codeDepartement).padStart(3, "0");
|
||||||
|
|
||||||
// Gets the associated features with a read and parse stream
|
// Gets the associated features with a read and parse stream
|
||||||
const pathToFeatures = join(__dirname, `public/cirs/${codeDepartement}.json`)
|
const pathToFeatures = join(__dirname, `public/cirs/${codeDepartement}.json`)
|
||||||
|
|||||||
Reference in New Issue
Block a user