z_fetch (zotonic_core v1.0.0-rc.17)
Fetch data from URLs. Interfaces to z_url_fetch and z_url_metadata.
Summary
Functions
Fetch data from an URL. Return the data as a data url.
Map (http) errors to readable format.
Fetch data from an URL. Let modules change the fetch options.
Perform a request and data from an URL. Let modules change the fetch options.
Fetch JSON data from an URL. Let modules change the fetch options. On success, the returned body is parsed with jsxrecord and returned.
Perform a request and fetch JSON data from an URL. Let modules change the fetch options. On success, the returned body is parsed with jsxrecord and returned.
Fetch data from an URL. Let modules change the fetch options.
Fetch the metadata from an URL. Let modules change the fetch options.
Functions
-spec as_data_url(string() | binary() | undefined, z_url_fetch:options(), z:context()) -> {ok, binary()} | {error, term()}.
Fetch data from an URL. Return the data as a data url.
Map (http) errors to readable format.
-spec fetch(Url, Options, Context) -> z_url_fetch:fetch_result() when Url :: string() | binary(), Options :: z_url_fetch:options(), Context :: z:context().
Fetch data from an URL. Let modules change the fetch options.
-spec fetch(Method, Url, Payload, Options, Context) -> Result when Method :: get | post | delete | put | patch, Url :: string() | binary(), Payload :: list() | binary() | map(), Options :: z_url_fetch:options(), Context :: z:context(), Result :: z_url_fetch:fetch_result().
Perform a request and data from an URL. Let modules change the fetch options.
-spec fetch_json(Url, Options, Context) -> {ok, JSON} | {error, term()} when Url :: string() | binary(), Options :: z_url_fetch:options(), Context :: z:context(), JSON :: term().
Fetch JSON data from an URL. Let modules change the fetch options. On success, the returned body is parsed with jsxrecord and returned.
-spec fetch_json(Method, Url, Payload, Options, Context) -> Result when Method :: get | post | delete | put | patch, Url :: string() | binary(), Payload :: list() | binary() | map(), Options :: z_url_fetch:options(), Context :: z:context(), Result :: {ok, term()} | {error, term()}.
Perform a request and fetch JSON data from an URL. Let modules change the fetch options. On success, the returned body is parsed with jsxrecord and returned.
-spec fetch_partial(Url, Options, Context) -> z_url_fetch:fetch_result() when Url :: string() | binary(), Options :: z_url_fetch:options(), Context :: z:context().
Fetch data from an URL. Let modules change the fetch options.
-spec metadata(string() | binary(), z_url_fetch:options(), z:context()) -> {ok, z_url_metadata:metadata()} | {error, term()}.
Fetch the metadata from an URL. Let modules change the fetch options.