smolter
Types

Result

A normalized operation result containing data or error.

Compatibility

ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.

Import from @kasperrt/smolter/react @kasperrt/smolter/preact

Signature

interface Result<T = unknown> {
  data?: T;
  error?: Error;
}

Usage

A normalized operation result containing data or error. Check error before reading data. A successful result can contain undefined; this object is not a discriminated success boolean.

const result = await fetcher.load("/tasks/1");

if (result.error) return result.error;
return result.data;

Fields

data

data?: T;

error

error?: Error;
View implementation ↗