Closed aaarichter closed 3 years ago
const { fetch } = require('gofer'); const ac = new AbortController(); // Node 15+ ac.signal.addEventListener('abort', () => console.log('Aborted!'), { once: true }); await Promise.race([ fetch('https://example.com', { signal: ac.signal }).text().catch(err => /* err this will say it was aborted */), async () => { return '<html>'; } ]).finally(() => ac.abort());