Skip to content

Commit af73c22

Browse files
authored
Feature/abortable fetch (#83)
Feature/abortable fetch
2 parents 711c4e9 + a27fddd commit af73c22

File tree

8 files changed

+447
-10049
lines changed

8 files changed

+447
-10049
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ const Frisbee = require('frisbee');
211211
212212
* `raw` - return a raw fetch response (new as of v2.0.4+)
213213
214+
* `abortToken` - some Symbol that you can use to abort one or more frisbee requests
215+
216+
* `signal` - an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) Signal used to cancel a fetch request
217+
214218
Upon being invoked, `Frisbee` returns an object with the following chainable methods:
215219
216220
* `api.auth(creds)` - helper function that sets BasicAuth headers, and it accepts `user` and `pass` arguments
@@ -223,6 +227,10 @@ Upon being invoked, `Frisbee` returns an object with the following chainable met
223227
224228
* `api.jwt(token)` - helper function that sets a JWT Bearer header. It accepts the `jwt_token` as a single string argument. If you simply invoke the function `null` as the argument for your token, it will remove JWT headers.
225229
230+
* `api.abort(token)` - aborts all current/queued requests that were created using `token`
231+
232+
* `api.abortAll()` - aborts all current/queued - i.e. `await`-ing in an interceptor - requests
233+
226234
* All exposed HTTP methods return a Promise, and they require a `path` string, and accept an optional `options` object:
227235
228236
* Accepted method arguments:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"Kyle Kirbatski <kkirbatski@gmrmarketing.com>"
3939
],
4040
"dependencies": {
41+
"@babel/runtime": "^7.3.1",
42+
"abortcontroller-polyfill": "^1.2.4",
4143
"caseless": "^0.12.0",
4244
"common-tags": "^1.8.0",
4345
"cross-fetch": "^3.0.2",

0 commit comments

Comments
 (0)