I have this code:
async function my_function() {
console.log("Hello");
let response = await fetch(url, {
mode: 'no-cors'
})
.then(response => response.json()) // THIS LINE
.then(response => {
console.log(response);
})
}
which works great if I include const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
in node.js. This however, does not run in the browser. When I run this code in google chrome I get this error
Uncaught (in promise) SyntaxError: Unexpected end of input
relating to the
.then(response => response.json()) // THIS LINE
line. What am I doing wrong?