matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

constructor equality fails #158

Open zhenyulin opened 6 years ago

zhenyulin commented 6 years ago
import fetch from 'isomorphic-fetch'; // global bindings
import nodeFetch from 'node-fetch';

const a = new Response();
const b = new nodeFetch.Response();

console.log(a instanceof nodeFetch.Response);
console.log(b instanceof Response);

the above code would output

false
false

use cases of the above check would be in error handling of fetch especially when extracting that to an external package, though instanceof might not be the best way to do the check.