i tried with postman, the 1st time run show error OK, but the 2nd sent POST again will crash… what wrong? @0xtim
p/s : Fixed my mistake, NOW it work OK. … forget replace this code
/// This Pokemon was not cached, we need to query the PokeAPI to verify.
return self.fetchPokemon(named: name).flatMap { res in
switch res.http.status.code {
case 200..<300:
/// The API returned 2xx which means this is a real Pokemon name
return self.cache.set(key, to: true).transform(to: true)
case 404:
/// The API returned a 404 meaning this Pokemon name was not found.
return self.cache.set(key, to: false).transform(to: false)
default:
/// The API returned a 500. Only thing we can do is forward the error.
throw Abort(.internalServerError, reason: "Unexpected PokeAPI response: \(res.http.status)")
}
}