Skip to content

reactive/data-client / .agents/skills/data-client-setup

data-client-setup

Verified

Install and set up @data-client/react or @data-client/vue in a project. Detects project type (NextJS, Expo, React Native, Vue, plain React) and protocol (REST, GraphQL, custom), then follows the bundled protocol-specific setup guide.

FileKindSize
SKILL.mdskill md13.9 KB
evals/evals.jsonconfig12.6 KB
references.jsonconfig523 B
references/DataClientPlugin.mdmarkdown6.6 KB
references/DataProvider.mdmarkdown6.6 KB
references/data-client-endpoint-setup.mdmarkdown8.5 KB
references/data-client-endpoint-setup/references/Endpoint.mdmarkdown20.9 KB
references/data-client-endpoint-setup/references/Endpoint.vue.mdmarkdown20.5 KB
references/data-client-graphql-setup.mdmarkdown4.8 KB
references/data-client-graphql-setup/references/auth.mdmarkdown1.9 KB
references/data-client-rest-setup.mdmarkdown7.6 KB
references/data-client-rest-setup/references/RestEndpoint.mdmarkdown45.2 KB
references/data-client-rest-setup/references/RestEndpoint.vue.mdmarkdown46.1 KB
references/data-client-rest-setup/references/auth.mdmarkdown9.4 KB
references/data-client-rest-setup/references/auth.vue.mdmarkdown9.7 KB
references/data-client-rest-setup/references/axios-migration.mdmarkdown25.4 KB
references/data-client-rest-setup/references/axios-migration.vue.mdmarkdown25.5 KB
references/data-client-rest-setup/references/django.mdmarkdown2.3 KB
references/data-client-rest-setup/references/fetch-migration.mdmarkdown4.0 KB
references/data-client-rest-setup/references/got-migration.mdmarkdown4.5 KB
references/data-client-rest-setup/references/hookifyResource.mdmarkdown6.0 KB
references/data-client-rest-setup/references/hookifyResource.vue.mdmarkdown6.3 KB
references/data-client-rest-setup/references/ky-migration.mdmarkdown3.9 KB
references/data-client-rest-setup/references/resource.mdmarkdown27.0 KB
references/data-client-rest-setup/references/resource.vue.mdmarkdown27.1 KB
references/data-client-rest-setup/references/superagent-migration.mdmarkdown4.1 KB
references/getDefaultManagers.mdmarkdown6.1 KB
references/getDefaultManagers.vue.mdmarkdown3.8 KB
references/installation.mdmarkdown4.0 KB
references/installation.vue.mdmarkdown2.7 KB
references/tanstack-query-migration.mdmarkdown31.1 KB

references/data-client-rest-setup/references/fetch-migration.md

View on GitHub
<!-- Generated by `yarn build:skills` from .agents/skills/data-client-rest-setup/references/fetch-migration.md. Edit the source, not this file. -->

# Raw fetch → @data-client/rest Migration

## Detection

Look for direct `fetch()` calls or thin wrappers around fetch in the codebase:

- `fetch(` calls with REST-style URLs (`/api/`, `/users/`, etc.)
- Custom wrapper functions that call `fetch` internally
- No HTTP client library in `package.json`

Search patterns:
- `\bfetch\(` — direct fetch calls
- `new Request\(` — Request object construction
- `\.json\(\)` — response parsing (common in fetch wrappers)

## Migration Rules

Convert `fetch()` call sites to `RestEndpoint`:

```ts
// Before: raw fetch wrapper
async function getUsers(token: string): Promise<User[]> {
  const res = await fetch('https://api.example.com/users', {
    headers: { Authorization: `Bearer ${token}` },
  });
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return res.json();
}

// After: RestEndpoint (auth moves to base class)
import { RestEndpoint } from '@data-client/rest';
import { User } from './User';

export const getUsers = new RestEndpoint({
  urlPrefix: 'https://api.example.com',
  path: '/users',
  schema: [User],
});
```

### Key conversions

| fetch pattern | RestEndpoint equivalent |
|---------------|----------------------|
| `headers` option | `getHeaders()` on base class |
| `res.ok` / status checks | Automatic — throws `NetworkError` on non-2xx |
| `res.json()` | Automatic — `parseResponse()` defaults to JSON |
| Base URL string concatenation | `urlPrefix` on base class |
| Query string building (`URLSearchParams`, template literals) | `searchParams` type + `searchToString()` override |
| `method: 'POST'` | `method` option on RestEndpoint |
| `body: JSON.stringify(data)` | Pass object directly — RestEndpoint serializes automatically |
| `credentials: 'include'` | `getRequestInit()` override on base class |
| `AbortController` / `signal` | `endpoint.extend({ signal })` for that one request ([Cancellation](axios-migration.md#cancellation)); a `signal` set when the endpoint is created aborts all of its requests |

### Fetch wrappers with shared config

```ts
// Before: custom fetch wrapper
function apiFetch(path: string, options?: RequestInit) {
  return fetch(`${BASE_URL}${path}`, {
    ...options,
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${getToken()}`,
      ...options?.headers,
    },
  });
}
const res = await apiFetch('/users');
const users = await res.json();

// After: base class captures shared config
class ApiEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
  urlPrefix = BASE_URL;

  getHeaders(headers: HeadersInit) {
    return {
      ...headers,
      Authorization: `Bearer ${getToken()}`,
    };
  }
}

export const getUsers = new ApiEndpoint({
  path: '/users',
  schema: [User],
});
```

### POST / mutation patterns

```ts
// Before
async function createUser(data: UserInput): Promise<User> {
  const res = await fetch('https://api.example.com/users', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(data),
  });
  return res.json();
}

// After
export const createUser = new RestEndpoint({
  path: '/users',
  method: 'POST',
  schema: User,
});
```

### Error handling

```ts
// Before
if (!res.ok) {
  const body = await res.json();
  throw new Error(body.message);
}

// After — RestEndpoint throws NetworkError on non-2xx
import { NetworkError } from '@data-client/rest';
try { ... } catch (err) {
  if (err instanceof NetworkError) {
    console.log(err.status);         // HTTP status code
    const body = await err.response.json();
    console.log(body.message);
  }
}
```

## Reference

- [RestEndpoint API](https://dataclient.io/rest/api/RestEndpoint) — lifecycle methods reference
- [NetworkError](https://dataclient.io/rest/api/RestEndpoint#fetchResponse) — error class
- [Authentication guide](https://dataclient.io/rest/guides/auth) — token and cookie patterns
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall