【发布时间】:2021-12-31 11:17:47
【问题描述】:
尝试从 OpenWeatherMap API 获取数据,然后尝试在控制台中显示它,但响应是不包含数据的 HTML 页面,响应状态为 200...它应该是 JSON 我在邮递员中尝试了 API,它有效并且显示了正确的数据,但在这里它不断抛出 Uncaught (in promise) SyntaxError: Unexpected token
const Fetching = async () => {
const response = await fetch('api.openweathermap.org/data/2.5/weather?&q=London&appid=31c3627d9d33b84c7a575fc11b6d7dfe');
const responsedata= await response.json();
console.log(responsedata);
};
Fetching();
【问题讨论】:
-
Unexpected token
标签: javascript html json fetch-api