I'm trying to run this script
const fetch = require('node-fetch');
function test() {
fetch('https://google.com')
.then(res => res.text())
.then(text => console.log(text))
}
test();
But i get this error
This expression is not callable. Type 'typeof import("(...)/node_modules/node-fetch/@types/index")' has no call signatures.ts(2349)
although it works when i use import
import fetch from 'node-fetch';
why and how to fix it?
defaultprop of the module. Howconst {default as fetch} = require('node-fetch')resolve?requireif you can useimport? I also suppose you canimportjsons, but if it fails, you can useimportfor modules andrequire()for json filesimportsyntax. I meantconst {default : fetch} = require('node-fetch')