当我尝试从 api( https://openweathermap.org/ )获取数据时,出现此错误。Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
这是我的代码。
import React from 'react';
import './App.css';
import Weather from "./components/Weather"
import 'bootstrap/dist/css/bootstrap.min.css'
import 'weather-icons/css/weather-icons.css'
const Api_Key="079b76b390ad70c628a14a9a141e5992";
class App extends React.Component {
constructor(){
super();
this.state={};
this.getWeather();
}
getWeather= async ()=>{
const api_call = await fetch(
`api.openweathermap.org/data/2.5/weather?q=London,uk&appid=${Api_Key}`,
);
const data = await api_call.json();
console.log(data);
}
render()
{
return (
<div className="App">
<Weather/>
</div>
)
}
}
export default App;
谢谢!