Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

2
New to .then() and not sure how to make template literal image appear
Post Flair (click to view more posts with a particular flair)
Post Body

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.

Author
Account Strength
100%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
9,114
Link Karma
553
Comment Karma
8,165
Profile updated: 2 days ago
Posts updated: 1 month 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
3 years ago