I am trying to build a weather app however, i am not sure why when entering a location to find the weather of a specific area, is only returning the longitude and latitude coordinates in my terminal on VS code instead of returning it on my console in chrome like I am telling it to. It should be returning my API call that I am making, returning a whole bunch of data that my API is showing. Here is my code:
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)
})
})