when I try to use fetch()
in function in a node environment, it throws me the error.
Command:
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => console.log(json))
Error message:
Why does this kind of error occur and how can I run the fetch()
method in my node environment?