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.
My title is a little confusing but bear with me. I am currently learning about APIs and am supposed to have 5 images come in from Flickr. This is the block of code I'm having issue with.
const successCallback = (position) => {
console.log(position);
let lat = position.coords.latitude;
let lon = position.coords.longitude;
console.log(lat, lon);
getBird(lat, lon).then(images => console.log(images.photos.photo)
).then(createImageTag.src = `https://live.staticflickr.com/634/23357649320_dbe6d4c825_z.jpg`)
};
When I hardcode the link, the image appears fine. However, it should be displaying each image one by one after a certain time (which I was planning to do with an interval timer). I was thinking about using a template literal for the ID, server ID, and secret but when I try to add it into the .src link, the whole thing stops working.
ex: const successCallback = (position) => {
console.log(position);
let lat = position.coords.latitude;
let lon = position.coords.longitude;
console.log(lat, lon);
getBird(lat, lon).then(images => console.log(images.photos.photo)
).then(createImageTag.src = `https://live.staticflickr.com/${images.photos.photo.server}/23357649320_dbe6d4c825_z.jpg`)
};
This ends up giving me "images is not defined". I'm assuming it's because it's outside of the first .then block but I'm not sure how to go about fixing it. I've tried replacing the console log with the .src I wanted to try but I get the same error.
Edit: The latitude and longitude are a different part of the assignment that needs me to show the user's position within the callback.
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...