如何解决为什么我的console.log仅在VS Code终端中返回,而不在Chrome Console中返回
我正在尝试构建一个天气应用程序,但是,我不确定为什么进入某个位置查找特定区域的天气时,为什么只在VS代码上返回终端中的经度和纬度坐标,而不是返回我的控制台是Chrome,就像我告诉的那样。应该返回我正在执行的API调用,返回我的API正在显示的一堆数据。这是我的代码:
const searchElement = document.querySelector('[data-location-search]')
const searchBox = new google.maps.places.SearchBox(searchElement)
searchBox.addListener('places_changed',() => {
const place = searchBox.getPlaces()[0]
if (place == null) return
const latitude = place.geometry.location.lat()
const longitude = place.geometry.location.lng()
fetch('/weather',{
method: 'POST',headers: {
'Content-Type': 'application/json','Accept': 'application/json'
},body: JSON.stringify({
lat: latitude,lng: longitude
})
}).then(res => res.json()).then(data => {
console.log(data)
// setWeatherData(data,place.formatted_address)
})
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。