Skip to content

Commit

Permalink
docs: update example for abort controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytelife26 committed Apr 12, 2021
1 parent 9a446c6 commit 3bf635f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/PetitioRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ export class PetitioRequest {
/**
* @param {AbortController} controller A controller instance that handles aborting the request.
* @return {*} The request object for further composition.
* @example Initiate a AbortController class and then attach it to the request object
* by doing `.signal(the_controller)`. Then you can abort the request by running
* the abort() function on the controller you created.
* @example
* ```ts
* const controller = new AbortController();
* const result = petitio(URL).signal(controller);
* setTimeout(() => controller.abort(), 5000) // serves as a request timeout
* ```
*/
*/
public signal(controller: AbortController): this {
this.controller = controller;
Expand Down

0 comments on commit 3bf635f

Please sign in to comment.