App.js:31 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

App.js:31 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

我正在尝试从天气 api 中获取数据,但出现错误 我的代码如下

class App extends React.Component{
  constructor(){
    super();
    this.state ={
      data : [],
    };
   // this.getWeather();
    this.getWeather();
  }
  
  getWeather =async()=>{
    const url = 'api.openweathermap.org/data/2.5/weather?q=toronto&appid='+apiKey;
    
    let req = await fetch(url);
    let res = await req.json();
}

网址需要以 http://https:// 开头。如果您省略它,您的浏览器将假定您打算在当前域中打开名为 api.openweathermap.org/etc/etc 的路径。