Loading
Current section: Network 7 exercises
Problem

Network errors

Loading exercise

Transcript

00:00 Receiving a response, whether it's a successful response or an error response, is not the only outcome of making a request. In fact, what happens if this fetch call here fails? If the requested server is down or having trouble processing this request, or maybe the client simply creates an invalid request instance? Well, to reproduce this scenario in tests,

00:20 we cannot really respond to this request with any response. We have to somehow fail this request promise altogether. And this will be your task in this exercise. One of the tasks. First, add the catch handling to this request promise. So when this fetch rejects, the function will throw a nice developer-friendly error message letting you know.

00:39 And the second task, head to the test case and complete this newly created test case for network errors by adding a runtime request handler that will force the fetch request to reject. You will use the standard response.error API to do that. It's going to be a nice challenge, but I know you're going to handle it just perfectly.