File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -470,7 +470,7 @@ You may cancel requests with `AbortController`. A suggested implementation is [`
470470An example of timing out a request after 150ms could be achieved as the following:
471471
472472``` js
473- import fetch from ' node-fetch' ;
473+ import fetch , { AbortError } from ' node-fetch' ;
474474
475475// AbortController was added in node v14.17.0 globally
476476const AbortController = globalThis .AbortController || await import (' abort-controller' )
@@ -484,7 +484,7 @@ try {
484484 const response = await fetch (' https://example.com' , {signal: controller .signal });
485485 const data = await response .json ();
486486} catch (error) {
487- if (error instanceof fetch . AbortError ) {
487+ if (error instanceof AbortError) {
488488 console .log (' request was aborted' );
489489 }
490490} finally {
@@ -868,4 +868,4 @@ Thanks to [github/fetch](https://github.com/github/fetch) for providing a solid
868868[error-handling.md]: https://github.com/node-fetch/node-fetch/blob/master/docs/ERROR-HANDLING.md
869869[FormData]: https://developer.mozilla.org/en-US/docs/Web/API/FormData
870870[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob
871- [File]: https://developer.mozilla.org/en-US/docs/Web/API/File
871+ [File]: https://developer.mozilla.org/en-US/docs/Web/API/File
You can’t perform that action at this time.
0 commit comments