This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
Trouble With Multiple API Requests (JS/Axios)
Post Flair (click to view more posts with a particular flair)
Post Body
I'm building a weather app. The API requires a request to locate the city's ID and another to request the weather.
I finally got the weather data in the console by using the code below...
const getCity = (e) => {
if (e.key === 'Enter') {
axios.get(cityURL)
.then((res) => {
return res.data[0].Key
})
.then((id) => {
return axios.get(`http://a-weather-api/${id}`)
})
.then((res) => {
console.log(res.data)
})
setLocation('')
}
}
The problem is I need more than the city id from the first request. I also need res.data[0].EnglishName
to display the city's name.
Is there an easier way to do this? Thanks!
Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
16,178
Link Karma
3,901
Comment Karma
12,189
Profile updated: 4 days ago
Posts updated: 1 year ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...