Documentation Index
Fetch the complete documentation index at: https://learn.nexudus.com/llms.txt
Use this file to discover all available pages before exploring further.
useTypedData
useTypedData<T, TShaped> builds on top of useData and the typed endpoint definitions found in src/api/endpoints.ts. It takes an endpoint object { url, type }, an optional createShape<TShaped>()([...]), and returns the shaped, typed resource.
Source: src/api/fetchData.ts
Signature
useTypedData simply calls useData<TShaped>(apiClient, endpoint?.url, { ...requestConfig, shape: shape?.fields }).
Pattern
- Pick an endpoint from
src/api/endpoints.ts(these exposetypewith the expected response) - Build a shape for the response using
createShape<typeof endpoint.type>()([...]) - Call
useTypedData(httpClient, endpoint, shape, { ...options })
Example – FAQ list
Example – Teams list with paging
Notes
- You can still pass
method,data, andqueryConfig– these flow through touseData. mockDatashort-circuits fetching – great for the editor and tests.
See also
- useData – Base hook with full config
- createShape – Build type-safe field lists
- useLocationByRouteContext – To get the correct
httpClient