FetchController

A FetchController fetches data from a URL and stores it in its data property.

OptionTypeDefaultValueDescription
urlstringThe URL to fetch data from.
initobject{}Optional - A fetch RequestInit object containing any custom settings to apply to the request.
parsefunction(data) => dataOptional - A function that accepts the raw fetched data and returns the data to store as data.
logbooleanfalseOptional - When true, the controller will log its data on each change.
dataanyfalseOptional - An initial value for the controller's data property.
PropertyTypeDescription
urlstringThe controller's current URL for data fetching. Changing this property will load new data from the new URL.
dataanyThe controller's data, stored from its last fetch request.
loadingbooleanWhether the controller is waiting for new data.
MethodDescription
refresh()Load new data from the current URL.

Example: