Skip to content

Persist Params that show up in path as well as root of the body #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ const { status, data: pets } = await findPetsByStatus({
console.log(pets[0])
```

If you have a path argument that you also want to appear in the root of the body payload, you can pass an optional third parameter to the created fetch method.

To continue from the example above, it would look something like this:

```ts
// fetch
const { status, data: pets } = await findPetsByStatus({
status: ['available', 'pending'],
undefined,
['keyToParamToBePersistedToBody']
})
```

### Typed Error Handling

A non-ok fetch response throws a generic `ApiError`
Expand Down Expand Up @@ -190,4 +203,4 @@ const body = arrayRequestBody([{ item: 1}], { param: 2})
// body type is { item: number }[] & { param: number }
```

Happy fetching! 👍
Happy fetching! 👍
Loading