tech(APIBretagneService.clean): l'API de data.bretagne renvoie un vide quand il n'y a pas de resultat, change l'implem pour ce cas
This commit is contained in:
parent
3495147045
commit
ffdd7ee95d
1 changed files with 3 additions and 2 deletions
|
@ -34,6 +34,7 @@ class APIBretagneService
|
|||
|
||||
def fetch_page(url:, params:, retry_count: 1)
|
||||
result = call(url:, params:)
|
||||
|
||||
case result
|
||||
in Failure(code:, reason:) if code.in?(401..403)
|
||||
if retry_count > 0
|
||||
|
@ -42,10 +43,10 @@ class APIBretagneService
|
|||
else
|
||||
fail "APIBretagneService, #{reason} #{code}"
|
||||
end
|
||||
in Failure(code:) if code == 204
|
||||
[]
|
||||
in Success(body:)
|
||||
body
|
||||
else # no response gives back a 204, so we don't try to JSON.parse(nil) to avoid error
|
||||
{ items: [] }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue