I am using fetch in my angular project and the code snippet is as follows:
fetch(
'www.example.com', {
headers: new Headers({
'Origin': location.origin
}),
mode: 'cors'
})
However, the website runs without problem but it gives error as below: error TS2304: Cannot find name 'fetch'. error TS2304: Cannot find name 'Headers'.
I searched the ways to solve this problem and tried add "lib": [ "es5", "dom"] in "compilerOptions" in tsconfig.json as below, but got the same error. I also tried adding "es6" inside, but no luck. I am running out of idea and could you please help.
"compilerOptions": {
"lib": [ "es5", "dom"],
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"allowUnreachableCode": true
},