I use
openweathermap to get some data (temperature) by letting user enter the Zip Code of his country.
I expect to return a response that I can extract the temperature from it. Instead I get the following response
Response {type: 'cors', url: 'http://api.openweathermap.org/data/2.5/weather?zip=90040&appid=xxxxxxxxxxxxxxxx', redirected: false, status: 200, ok: true, …}
body: ReadableStream
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "http://api.openweathermap.org/data/2.5/weather?zip=90040&appid=xxxxxxxxxxxxxxxx"
[[Prototype]]: Response
I can't get any data from it. Any advice how I can get temperature of that response?
this is my URL build code
const feelings = document.getElementById('feelings')
const baseURL = 'http://api.openweathermap.org/data/2.5/weather?zip='
const ZIP = document.getElementById('zip')
const getWeatherData = async (baseURL, ZIP, KEY) => {
await fetch(`${baseURL}${ZIP}&appid=${KEY}`)
.then(function(data){
postData('/addData', {
temp: data.body,
date: newDate,
feelings: feelings
})
})
}
and the server side code
app.post('/addData', (req, res) => {
newEntry = {
temp: req.body.temp,
date: req.body.date,
feelings: req.body.feelings
}
projectData.push(newEntry)
res.send(projectData)
})
What I have tried:
I tried to get the temperature from the response but I failed to extract it from the above response.