【发布时间】:2020-06-17 06:49:27
【问题描述】:
我已经克隆了这个项目https://github.com/LaurenceHo/react-weather-app#webpack-reactjs-and-typescript
我已正确执行所有步骤,我已在 Map Forecast API 的 https://api.windy.com/keys 此处创建了我的新密钥,并在此处作为说明输入 https://github.com/LaurenceHo/react-weather-app/blob/master/src/views/weather-map.tsx
现在我运行服务器,我得到这个方法的错误getWeather
我在我的网络和控制台中查找,这些是我可以看到的错误,但我不知道如何修复它
这是带有方法的api
export const getWeatherByTime = (
latitude: number,
longitude: number,
time: number,
exclude: string,
units: string
): Promise<Forecast> => {
const requestUrl =
`${CLOUD_FUNCTION_URL}getWeather?lat=${latitude}&lon=${longitude}&time=${time}` +
`&exclude=${encodeURIComponent(exclude)}&units=${encodeURIComponent(units)}`;
return fetch(requestUrl)
.then(checkStatus)
.then(parseJSON)
.then((data: any) => data);
};
如何解决问题?我该如何解决?
【问题讨论】:
-
您的开发服务器是否正在运行?它正在打电话给
localhost:3000... -
是的,它在localhost:8080 上运行,但请求已发送到localhost:3000..can,这是问题所在吗?
标签: javascript reactjs rest api fetch