0
const feedImages = $('.feed-image');
$(document).ready(function() {
$.get('https://us-central1-codesmith-curriculum-server.cloudfunctions.net/app/images', function(data) {
    for (let i = 0; i < data.length; i++) {
        $(feedImages[i]).attr('src', data[i])
    }
})  
})

Hi all, I am making an Instagram clone. I am using a get request to get data from a URL. This URl contains an array of more URLS that are links to images. I used a for loop to iterate through the feedImages and the data to apply one data element to each feedImages src. Some of the links are broken. How can I filter through these broken links and exclude them? I tried using if (status !== 'success') but they all return 'success' so that isn't working. Any advice is appreciated. Thanks!

  • See [this specific](https://stackoverflow.com/a/3235968/519413) answer in the first duplicate for the solution - ie. hook to the `error` event of the `img` elements, and use that to hide the image if it cannot be loaded. – Rory McCrossan Oct 03 '22 at 17:39

0 Answers0