node-fetch–typeofimport("[…]/node-fetch/index")'没有调用签名

从这里复制:https : //github.com/node-fetch/node-fetch#json ...我的代码:

const fetch = require('node-fetch');

async function doFetch() {
    const response = await fetch('https://api.github.com/users/github');
    const data = await response.json();

    console.log(data);
}

doFetch()

错误信息——指的是fetch('https://...)调用:

This expression is not callable.
Type 'typeof import("[...]/node_modules/@types/node-fetch/index")' has no call signatures.

我已经搜索过这个网站和其他网站,这个错误在许多模块中似乎很常见,尽管我只能找到使用import而不是require. 我猜这很简单,但我就是不知道如何用 require 语法解决这个问题。

我究竟做错了什么?提前致谢!


如果重要:JavaScript(不是 TypeScript)。节点.js。Mac 上的 VSCode。错误消息是由dbaeumer.vscode-eslint插件生成的。


以上是node-fetch–typeofimport("[…]/node-fetch/index")'没有调用签名的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>