android-components / mozilla.components.concept.fetch / Client / fetch

# fetch

`abstract fun fetch(request: Request): Response` (source)

Starts the process of fetching a resource from the network as described by the Request object.

A Response may keep references to open streams. Therefore it's important to always close the Response or its Response.Body.

Use the `use()` extension method when performing multiple operations on the Response object:

    client.fetch(request).use { response ->
        // Use response. Resources will get released automatically at the end of the block.
    }

Alternatively you can use multiple `use*()` methods on the Response.Body object.

### Parameters

`request` - The request to be executed by this Client.

### Exceptions

`IOException` - if the request could not be executed due to cancellation, a connectivity problem or a timeout.

Return
The Response returned by the server.