getting started learning React. Trying to fetch list of users from jsonplaceholder. throwing error what .json() undefined metod and fetch() is undefined too. sound like rubbish. As i understand node.js dont have fetch() and i must downloading lib but that lib dont know what is .json()
const gettingData = async () => {
const response = await fetch('https://jsonplaceholder.typicode.com/users/1');
const data = await response.json();
console.log(data)
};
gettingData()
.catch((err) => {
console.log(err)
});
this code throwing
ReferenceError: fetch is not defined
at gettingData (C:\Dev\chartsandtable\src\components\Pie\PieData.js:5:22)
at Object.<anonymous> (C:\Dev\chartsandtable\src\components\Pie\PieData.js:9:1)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
so i find familiar question install node-fetch and get another one err - .json() not a method. How fix it? Or switch on axios?