add rejection to UF search promises when an empty list is returned #607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Relacionada
#600
Causo do Erro
Quando é feita a chamada para o endpoint
/api/ibge/municipios/v1/AP
sem especificar um provedor, o service vai executar a chamada para os três provedores disponíveis, o que responder primeiro esse será o resultado da chamada ao endpoin.Acontece que para alguns casos o primeiro provedor a responder retorna um lista vazia, ignorando os outros possíveis resultados validos dos outros providers
Solução
Foi implementado a util function rejectWhenEmptyArray, que rejeita a promise quando o resultado da chama retorna uma lista vazia. Dessa forma os outros providers que responderem depois tmb serão considerados
Teste local
Ao executar localmente é necessário adicionar um delay na função
getContiesByUf