Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Fix post() and options() types (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow authored May 8, 2023
1 parent 5d0b22a commit e730cd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-melons-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openapi-fetch': patch
---

Fix post() and options() types
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ export default function createClient<Paths extends {}>(options?: ClientOptions)
},
/** Call a POST endpoint */
async post<P extends PathsWith<Paths, 'post'>>(url: P, init: FetchOptions<FilterKeys<Paths[P], 'post'>>) {
return coreFetch<P, 'put'>(url, { ...init, method: 'POST' } as any);
return coreFetch<P, 'post'>(url, { ...init, method: 'POST' } as any);
},
/** Call a DELETE endpoint */
async del<P extends PathsWith<Paths, 'delete'>>(url: P, init: FetchOptions<FilterKeys<Paths[P], 'delete'>>) {
return coreFetch<P, 'delete'>(url, { ...init, method: 'DELETE' } as any);
},
/** Call a OPTIONS endpoint */
async options<P extends PathsWith<Paths, 'options'>>(url: P, init: FetchOptions<FilterKeys<Paths[P], 'options'>>) {
return coreFetch<P, 'delete'>(url, { ...init, method: 'OPTIONS' } as any);
return coreFetch<P, 'options'>(url, { ...init, method: 'OPTIONS' } as any);
},
/** Call a HEAD endpoint */
async head<P extends PathsWith<Paths, 'head'>>(url: P, init: FetchOptions<FilterKeys<Paths[P], 'head'>>) {
Expand Down

0 comments on commit e730cd8

Please sign in to comment.