Instafeed exclude by tag or post

114 Views Asked by At

I would like to exclude certain posts from the Instafeed. Either by tag or by some post ID. I know how to apply a filter that only lets pass images specified by tag:

  filter: function(image) {
    console.log(image);
    return image.tags.indexOf('thisTagPasses') >= 0;
  }

However, I have no idea how to exclude/skip certain images. Any ideas?

1

There are 1 best solutions below

7
MauriceNino On

Just use the filter() function like so:

const excludeItems = (arr, propertyName, filterArr) => {
    return arr.filter(el => filterArr.indexOf(el[propertyName]) !== -1).slice();
}

let instafeedArr = []; // your data

// Filter out all elements where arr.id === 123
let filteredArr = excludeItems(instafeedArr, "id", [123]);

// Filter out all elements where arr.id === 123 or arr.id === 456
let filteredArr = excludeItems(instafeedArr, "id", [123, 456]);