boost::burl::request_builder::as

Asynchronously send the request and convert the body.

Synopsis

template<
    class T,
    class... Args>
capy::task<T>
as(Args&&... args) &&;

Description

Sends the request and converts the response body to T by calling tag_invoke with body_to_tag.

A status code of 400 or above throws without reading the body. Use try_as to inspect an error response.

Example

auto r = co_await c.get("https://example.com")
    .as<std::string>();

Exceptions

Name

Thrown on

std::system_error

The request, status code, or conversion failed.

Return Value

An awaitable yielding the converted body.

Template Parameters

Name

Description

T

The type to convert the body to.

Parameters

Name

Description

args

Additional arguments forwarded to the conversion.

See Also