How do I fetch data from a fetch request?

  • 0
    Good day!
    Got up completely.
    The task is to "make a request at the URL https://picsum.photos/v2/list? page = 1 & amp; limit = 10 and after receiving this display a list of pictures on the screen "
    I don't understand how to get the images from fetch and display them.
    Part of the code:
    const options = {
                method: 'GET',
                mode: 'cors'
            };
            fetch(`https://picsum.photos/v2/list?page=${heightValue}&limit=${weightValue}`, options)
            .then((response) => {
            console.log('response', response);
            return response.json();
            })
            .then((data) => {
            console.log('data', data);
            })
            .catch(() => { console.log('error') });
    JavaScript Elisabeth Hernandez, Oct 30, 2019

  • 3 Answers
  • 0
    So what exactly is your problem? In data, do you get an array of images?
    Anonymous

  • 0
    Anonymous

  • 0
    Loop through the data array and output the images (url) to the img tag
    Emma Kerr

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!