Files
main.tsmain
What you'll learn
- Import HttpModule with options and make requests through HttpService, converting its observables with firstValueFrom
- Read an AxiosError: response status, timeout code, no response at all
- Translate upstream failures into NotFoundException, GatewayTimeoutException and BadGatewayException instead of leaking a 500
Press Run tests to start the app. Its log appears here.Graded endpoints
HttpService fetched the list from the breeds service and the handler returned its data
A breed the service knows
The upstream answered 404; catchError translated the AxiosError into this API's own 404
The upstream needs 2.6 seconds and the timeout is 2: axios aborted with ECONNABORTED, answered as 504
A 503 from the upstream is not this API's fault and not the client's: 502
A cat whose breed the service can describe
The database and the upstream, combined in one handler