how can i invoke fetch method inside single js file?
I created file with content
const fetch = require("fetch").fetchUrl
fetch("https://jsonplaceholder.typicode.com/todos/1").then(res =>
res.json()).then(d => {console.log(d)
})
then i invoke this
node fetch.js
but receiving error
fetch(“https://jsonplaceholder.typicode.com/todos/1”).then(res =>
^TypeError: Cannot read properties of undefined (reading ‘then’)
at Object. (C:reporustfetch.js:2:55)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47