@updevs/sdk-client
v1.0.0
Published
Framework-agnostic client for APIs built with the UpDevs .NET SDK: HTTP, stores, filters, errors and auth. Runs on web, Expo/React Native and Node.
Readme
@updevs/sdk-client
Framework-agnostic client for APIs built with the UpDevs .NET SDK: HTTP client, stores, search filters, typed errors and auth sessions. No React, no DOM: it runs in browsers, Expo/React Native (Hermes) and Node.
npm install @updevs/sdk-clientimport { createAuthSession, createHttpClient, cookieSessionStrategy, EntityStore } from '@updevs/sdk-client';
const baseUrl = 'https://api.example.com';
const session = createAuthSession({ http: createHttpClient({ baseUrl }), strategy: cookieSessionStrategy() });
const http = createHttpClient({
baseUrl,
getAccessToken: session.getAccessToken,
onUnauthorized: session.handleUnauthorized,
});
interface Product { id: string; name: string }
const products = new EntityStore<Product>(http, { baseUrl: 'products' });
const page = await products.search({ pageIndex: 0, pageSize: 20 });- Failures are
ApiErrors. Status588carries the business validation errors:error.getFieldErrors(). - The wire models are generated from the .NET sources.
- For React hooks use
@updevs/sdk-react.
Full documentation: https://github.com/eestein/updevs-sdk-react#readme
