Skip to content

Commit

Permalink
🏭 Add HEAD and OPTIONS http methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Oct 11, 2017
1 parent fd3bcf7 commit 3c30844
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 7 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ wretch("...").formUrl(alreadyEncodedForm).post()
*You can pass the fetch options here if you prefer.*
| [get](#getopts--) | [delete](#deleteopts--) | [put](#putopts--) | [patch](#patchopts--) | [post](#postopts--) |
|-----|-----|-----|-----|-----|
| [get](#getopts--) | [delete](#deleteopts--) | [put](#putopts--) | [patch](#patchopts--) | [post](#postopts--) | [head](#headopts--) | [opts](#optsopts--) |
|-----|-----|-----|-----|-----|-----|-----|
#### get(opts = {})
Expand Down Expand Up @@ -542,6 +542,21 @@ Perform a post request.
wretch("...").json({...}).post({ credentials: "same-origin" })
```
#### head(opts = {})
Perform a head request.
```js
wretch("...").head({ credentials: "same-origin" })
```
#### opts(opts = {})
Perform an options request.
```js
wretch("...").opts({ credentials: "same-origin" })
```
## Catchers
*Catchers are optional, but if you do not provide them an error will still be thrown in case of an http error code received.*
Expand Down
2 changes: 1 addition & 1 deletion dist/bundle/wretch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/bundle/wretch.js.map

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions dist/wretcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,58 @@ export declare class Wretcher {
internalError: (cb: (error: WretcherError) => void) => any;
onAbort: (cb: (error: Error) => void) => any;
};
/**
* Performs a head request.
*/
head(opts?: {}): {
res: <Result = Response>(cb?: (type: Response) => Result) => Promise<Result>;
json: <Result = {
[key: string]: any;
}>(cb?: (type: {
[key: string]: any;
}) => Result) => Promise<Result>;
blob: <Result = Blob>(cb?: (type: Blob) => Result) => Promise<Result>;
formData: <Result = FormData>(cb?: (type: FormData) => Result) => Promise<Result>;
arrayBuffer: <Result = ArrayBuffer>(cb?: (type: ArrayBuffer) => Result) => Promise<Result>;
text: <Result = string>(cb?: (type: string) => Result) => Promise<Result>;
perfs: (cb?: (type: any) => void) => any;
setTimeout: (time: number, controller: any) => any;
controller: () => [any, any];
error: (code: string | number, cb: any) => any;
badRequest: (cb: (error: WretcherError) => void) => any;
unauthorized: (cb: (error: WretcherError) => void) => any;
forbidden: (cb: (error: WretcherError) => void) => any;
notFound: (cb: (error: WretcherError) => void) => any;
timeout: (cb: (error: WretcherError) => void) => any;
internalError: (cb: (error: WretcherError) => void) => any;
onAbort: (cb: (error: Error) => void) => any;
};
/**
* Performs an options request
*/
opts(opts?: {}): {
res: <Result = Response>(cb?: (type: Response) => Result) => Promise<Result>;
json: <Result = {
[key: string]: any;
}>(cb?: (type: {
[key: string]: any;
}) => Result) => Promise<Result>;
blob: <Result = Blob>(cb?: (type: Blob) => Result) => Promise<Result>;
formData: <Result = FormData>(cb?: (type: FormData) => Result) => Promise<Result>;
arrayBuffer: <Result = ArrayBuffer>(cb?: (type: ArrayBuffer) => Result) => Promise<Result>;
text: <Result = string>(cb?: (type: string) => Result) => Promise<Result>;
perfs: (cb?: (type: any) => void) => any;
setTimeout: (time: number, controller: any) => any;
controller: () => [any, any];
error: (code: string | number, cb: any) => any;
badRequest: (cb: (error: WretcherError) => void) => any;
unauthorized: (cb: (error: WretcherError) => void) => any;
forbidden: (cb: (error: WretcherError) => void) => any;
notFound: (cb: (error: WretcherError) => void) => any;
timeout: (cb: (error: WretcherError) => void) => any;
internalError: (cb: (error: WretcherError) => void) => any;
onAbort: (cb: (error: Error) => void) => any;
};
/**
* Sets the request body with any content.
* @param contents The body contents
Expand Down
14 changes: 14 additions & 0 deletions dist/wretcher.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3c30844

Please sign in to comment.