fetchAndMap

suspend fun <T> fetchAndMap(url: URL, mapper: CoursesClient.ResponseMapper<T>): T

Makes a GET request to the given URL and returns the mapped response.

Return

The result of mapper.map(response), where response is a HttpResponse containing the response.

Parameters

url

The URL to which the GET request is made.

mapper

A ResponseMapper that converts the HttpResponse instance to the desired format.

Throws

If an issue occurs while making the request, which includes cases such as an unknown host. This is an instance of UnexpectedResponseException if the status code isn't 2xx.