Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find name 'fetch'

I am able use fetch api newly created reactjs app. But I am using this template and it says cant find fetch api. enter image description here

whats wrong here? I encounter smilar issues how can I fix it?

like image 707
TyForHelpDude Avatar asked Feb 17 '17 08:02

TyForHelpDude


1 Answers

If you are using Typescript 2.8.0+ fetch is included in the standard lib.

You will need to use "--lib dom" or add "dom" in your tsconfig.json:

  1. old ❌
{
  "compilerOptions": {
    "lib": ["dom"],
  }
}

  1. new ✅
{
  "compilerOptions": {
    "lib": ["DOM"],
  }
}

like image 94
meldim Avatar answered Oct 19 '22 08:10

meldim