Captain is currently in ALPHA. We are happy to get your feedback
SDK
Use Inventory

Module: use-inventory

Table of contents

Functions

Functions

useInventory

useInventory<T>(key, config?): SWRResponse<T, any>

A custom hook to retrieve items stored in the inventory store, such as Stable Diffusion configurations, apps, datasets, etc.

Type parameters

NameDescription
TThe type of the data being retrieved from the inventory store.

Parameters

NameTypeDescription
keystringThe key to identify which item to retrieve from the inventory store.
config?anyOptional configuration for the SWR hook.

Returns

SWRResponse<T, any>

  • The response object from the SWR hook, containing the data, error, and status of the fetch request.

Function

useInventory

Example

const { data, error } = useInventory<StableDiffusion>('stable-diffusion-config');
 
if (error) return <div>Error loading inventory</div>;
if (!data) return <div>Loading...</div>;
 
return (
  <div>
    <h1>Stable Diffusion Inventory</h1>
    <pre>{JSON.stringify(data, null, 2)}</pre>
  </div>
);

Defined in

react/dist/esm/use-inventory/index.js:28