Skip to content

Commit

Permalink
fix: createHTTPMethod test allow override
Browse files Browse the repository at this point in the history
  • Loading branch information
fzn0x committed Jul 15, 2024
1 parent 2db60c1 commit d63e0d6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ try {
}
```

## Response Cloning

You need to use `throwOnError: true` to enable Response clone feature.

```ts
try {
const res = await createRequest(
'https://jsonplaceholder.typicode.com/todos/1',
{},
{},
{
throwOnError: true,
}
)

const response2 = res.clone()

expect(res).to.be.an.instanceOf(Response)
expect(response2).to.be.an.instanceOf(Response)
expect(await res.json()).to.be.an.instanceOf(Object)
expect(await response2.json()).to.be.an.instanceOf(Object)
} catch (err) {
console.log(err)
}
```

## Hooks

Hooks is supported and expected to not modifying the original result by design.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/create-http-method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('createHTTPMethod', () => {
{}
)
} catch (err) {
expect((err as Error)?.message).equals(undefined)
expect((err as Error)?.message).equals('fetch failed')
}
})
})

0 comments on commit d63e0d6

Please sign in to comment.