cleaned rate limiting in osm

main
Inga 🏳‍🌈 1 year ago
parent 50d84576fc
commit b8f9ee0e76
  1. 7
      src/clients/geocoding/osm.ts

@ -29,8 +29,9 @@ export const createOsmClient = (): Geocoder => {
}); });
return { return {
geocode: async (query) => { geocode: async (query) =>
const result = await queue.add(() => geocoder.geocode(query)); queue.add(async () => {
const result = await geocoder.geocode(query);
if (!result.length) { if (!result.length) {
throw new Error('No results found'); throw new Error('No results found');
@ -58,6 +59,6 @@ export const createOsmClient = (): Geocoder => {
latitude: meanLatitude, latitude: meanLatitude,
longitude: meanLongitude, longitude: meanLongitude,
}; };
}, }),
}; };
}; };

Loading…
Cancel
Save