Home » Javascript » accessing the api sublinks

accessing the api sublinks

Posted by: admin October 18, 2018 Leave a comment

Questions:
   componentDidMount = () => {
    fetch('https://api.teleport.org/api/urban_areas/?embed=ua:item/ua:images')
    .then(response => response.json())
    .then(data => {
      console.log(data)
      this.setState({
        images: data
      })
      console.log(this.state.images._embedded)
    })
  }

I am currently a student and working on a project that reads data from an api and writes it to the page. I am trying to get to the part of this api where I can get a url to some images. Before, I only used apis that are very simple to work with and have always used dot notation to get in the data and the and inner parts of it. So far, I got to that ‘_embedded’ part using dot notation, ‘data._embedded’. But I can’t figure out how to get in that part that says ‘ua:item’. I eventually need to get to the ‘mobile’ part to get to the image url. This is a React project by the way, if it makes any difference for this particular issue. Thanks a lot in advance!

enter image description here

Answers: