A Fetch component lets you pull live data from a third-party REST API endpoint directly into your app.

How to use

Before you can use the Fetch component, you'll need to set up your REST Services & Endpoints.

Once you have a Service and Endpoint configured, you can add a Fetch component to your screen. The Fetch component allows you to select the Service and Endpoint, and pass data to any query parameters you specified.

After you've configured the Service and Endpoint, the data returned in the response will be available to any components you nest inside the Fetch component - such as a List

There's several Triggers available on the Fetch component that allow you to take Actions based on different conditions.

Data Properties

NameDescription
ServiceName of the REST API service you have created inside the Draftbit app.
EndpointName of the API endpoint to fetch data
Query ParamsOption available if the endpoint has a query parameter attached to it. For example, https://example-data-draftbit.com/books?_limit={{limitParam}} has a query parameter called limitParam. On the Fetch component, you can define a custom value for this parameter.
Poll IntervalAllows defining a value in milliseconds (ms) to refetch data in the background at a time interval from the endpoint. For example, if you set the value to 3000 ms, the Fetch component will automatically refetch the data at every 3 seconds.

Triggers

NameDescription
On DataExecutes when data has been successfully loaded.
On Processing(1xx).Executes when the response status is 1xx (informational response)
On Success (2xx).Executes when the response status is 2xx (successful)
On Redirect (3xx).Executes when the response status is 3xx (redirection)
On Request Error (4xx).Executes when the response status is 3xx (client error)
On Unauthorized Request.Executes when the response status is 401
On Not Found (404).Executes when the response status is 404
On Server Error (5xx).Executes when the response status is 5xx (server error)

📘

Learn how to set and use the Fetch and List component in Fetching Data.