I am trying to fetch API from an URL in JavaScript and this is my code:
try {
let response = await fetch(URL, {
method: 'GET',
});
let data = await response.json();
console.log(data);
}
catch(err) {
console.log("Err")
}
Error I got:
(node:403113) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/deps/undici/undici:4045
if (socket[kParser].timeoutType !== TIMEOUT_IDLE) {
^
TypeError: Cannot read properties of undefined (reading 'timeoutType')
at _resume (node:internal/deps/undici/undici:4045:33)
at resume (node:internal/deps/undici/undici:4015:7)
at connect (node:internal/deps/undici/undici:4004:7)
Node.js v18.6.0
I googled and what I know is I should run it on Node.js v16 :((