Skip to content

Commit

Permalink
docs: Add config sharing section to restendpoint docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Jan 17, 2024
1 parent 802719b commit b5f79ee
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions docs/rest/api/RestEndpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ const getTodo = new RestEndpoint({
});
```

### Configuration sharing

Use [RestEndpoint.extend()](#extend) instead of `{...getTodo}` (spread)

```ts
const updateTodo = getTodo.extend({ method: 'PUT' });
```

### Managing state

<TypeScriptEditor>
Expand All @@ -127,17 +135,12 @@ export class Todo extends Entity {
}
}

const getTodo = new RestEndpoint({
urlPrefix: 'https://jsonplaceholder.typicode.com',
path: '/todos/:id',
schema: Todo,
});
const updateTodo = new RestEndpoint({
export const getTodo = new RestEndpoint({
urlPrefix: 'https://jsonplaceholder.typicode.com',
path: '/todos/:id',
method: 'PUT',
schema: Todo,
});
export const updateTodo = getTodo.extend({ method: 'PUT' });
```

</TypeScriptEditor>
Expand Down Expand Up @@ -419,7 +422,9 @@ class QSEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
import { RestEndpoint, RestGenerics } from '@data-client/rest';
import qs from 'qs';

export default class QSEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
export default class QSEndpoint<
O extends RestGenerics = any,
> extends RestEndpoint<O> {
searchToString(searchParams) {
return qs.stringify(searchParams);
}
Expand Down

0 comments on commit b5f79ee

Please sign in to comment.