From ebec172c8b6441ae36c5c0f9b17296ca8128ff87 Mon Sep 17 00:00:00 2001 From: Simon Buerger Date: Tue, 17 Apr 2018 09:49:01 +0200 Subject: [PATCH] Add support for AbortController (#54) --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index 71c60a8..07a5deb 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,10 @@ export default typeof fetch=='function' ? fetch.bind() : function(url, options) resolve(response()); }; + if (options.signal) options.signal.onabort = () => request.abort(); + + request.onabort = reject; + request.onerror = reject; request.send(options.body);