Home > @plasmicapp/query > usePlasmicQueryData

usePlasmicQueryData() function

Fetches data asynchronously. This data should be considered immutable for the session -- there is no way to invalidate or re-fetch this data.

Signature:

export declare function usePlasmicQueryData<T>(key: Key, fetcher: Fetcher<T>): {
    data?: T;
    error?: Error;
    isLoading?: boolean;
};

Parameters

Parameter Type Description
key Key a unique key for this data fetch; if data already exists under this key, that data is returned immediately.
fetcher Fetcher<T> an async function that resolves to the fetched data.

Returns:

{ data?: T; error?: Error; isLoading?: boolean; }

an object with either a "data" key with the fetched data if the fetch was successful, or an "error" key with the thrown Error if the fetch failed.