Skip to content
Snippets Groups Projects

Feat/insee code

Merged Hugo SUBTIL requested to merge feat/insee-code into main
2 files
+ 6
1
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 5
1
@@ -12,8 +12,8 @@ const API_URL = 'https://apicarto.ign.fr/api/codes-postaux/communes'
*/
async function getInseeCode(postalCode, city) {
try {
const response = await axios.get(`${API_URL}/${postalCode}`)
log('info', `Query getInseeCode for postalCode ${postalCode} / ${city}`)
const response = await axios.get(`${API_URL}/${postalCode}`)
if (response.data.length === 1) {
return response.data[0].codeCommune
@@ -26,6 +26,10 @@ async function getInseeCode(postalCode, city) {
return filteredResponse[0].codeCommune
}
} catch (error) {
log(
'error',
`Query getInseeCode failed for postalCode ${postalCode} / ${city}`
)
return null
}
}
Loading