Chapter 24: Caching : Crash for second POST

i tried with postman, the 1st time run show error OK, but the 2nd sent POST again will crash… what wrong? @0xtim
image

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)")
                }
            }

@tanner0101 Can you please help with this when you get a chance? Thank you - much appreciated! :]

1 Like

@choioi Fyi this crash was introduced in 3.2.0 of Vapor, so may not have actually been your fault. If you run swift package update you should find it has been fixed

1 Like