fetchJs uses promises.  Also checking type with .constructor is quite fragile, use typeof instead