Skip to content
Snippets Groups Projects
Commit 1f7c8253 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

simplify logic

parent 4a5dc45f
No related branches found
No related tags found
1 merge request!36fix(insee): handle parsing partial cities
......@@ -21,12 +21,11 @@ async function getInseeCode(postalCode, city) {
} else {
if (!city) throw new Error('No city')
const parsedInput = sanitizeCity(city)
const parsedCity = sanitizeCity(city)
const filteredResponse = response.data.filter(city => {
const parsedCity = sanitizeCity(city.nomCommune)
return parsedCity === parsedInput || parsedCity.includes(parsedInput)
})
const filteredResponse = response.data.filter(commune =>
sanitizeCity(commune.nomCommune).includes(parsedCity)
)
return filteredResponse[0].codeCommune
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment