node-fetch SyntaxError Cannot use import statement outside a module nodejs fetch call error solved

preview_player
Показать описание
In this video we fixed node-fetch SyntaxError Cannot use import statement outside a module in Node js.We make an api call from NodeJs project and use Fetch.But we got a Reference error.Fetch is not defined .That means Fetch is not implemented in NodeJs.To fix it,we use node-fetch npm package .But we got SyntaxError Cannot use import statement outside a module.We have two options two fix this SyntaxError Cannot use import statement outside a module.
Рекомендации по теме
Комментарии
Автор

the point of using dynamic lazy import is so that you can still use the ESM- only version v3.x.
if you want to stick to using require('node-fetch') then you must use v2.x

Автор

thanks
this tutorial
help
thanks sir
love from seattle waghinston

gabrielfono