./src/App.js
Line 15: Parsing error: await is a reserved word
13 | getWeather = async=()=>{
14 |
15 | const api_call = await fetch('http://api.openweathermap.org/data/2.5/weather?q=Manchester,uk&appid=${API_KEY}');
| ^
16 |
17 | const data = await api_call.json();
如何消除这个错误?
最佳答案
由于您是这门语言的新手,我建议您不要使用这种方式。这就是所谓的箭头函数
。
async () => { /*...*/ };
// same to
async function () { /*...*/ };
并将其与参数一起使用:
async (param_1, param_2) => { /*...*/ };
// same to
async function (param_1, param_2) { /*...*/ };
就您而言,问题可能来自
// remove "=" character after "async" keyword here
async=()=> { /*...*/ }
希望这有帮助!
关于javascript - react :Parsing error: await is a reserved word,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52967965/