Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
668 B
2
Indexable
Never
let errors = [];
for await (suburb of data) {
    await fetch(
        `https://nominatim.openstreetmap.org/search.php?q=${`${suburb.city} ${suburb.state} ${suburb.postCode}, ${suburb.country}`}&polygon_geojson=1&format=json`,
      )
        .then((res) => res.json())
        .then(async (data) => {
          const boundaryData = data?.find((v) => v.class === 'boundary');
          if (boundaryData && !!boundaryData.geojson && boundaryData.geojson?.coordinates) {
              a = 1;
              console.log(suburb.city)
          } else { errors.push(suburb); console.log('ERROR SUBURB', suburb.city) }
        })

}
console.log('ENDDDDDDDD!!!!-------------')