Learn how to load data with deco.cx using Loaders and Sections, allowing business users to customize data fetching.
props
.
In this tutorial you’ll learn how to fetch data from an external API and feed
that into a Section using Loaders.
Open in your browser this URL with params for the Dog Fact API
At this point, you can check in the admin (in your local environment) that this component can already be used with static data, which doesn’t make much sense for our use case.
fetch
. Loaders can be “plugged” into a Section via one
of the Section’s props
, and that happens based on the return type of the
Loader (the return type of the Loader is the input type of the Section).
Props
of your loader.loader
in the same file as your Section.
Note: The SectionProps
type is a helper type that is used to infer the
return type of the loader.
DECO_ENV_NAME={environment_name} deno task start
.https://deco.cx/admin
in your site and make sure that your
environment is selected in the Environment Selector in the upper right corner
of the Admin.Sections
and search for DogFacts in the left sidebar.props
to
make it more reusable in deco.cx’s Admin.