Delete item from subscribe

Hey everyone, I need help.

I would like not showing the first playlist from the channel. I’m using YouTube API to fetch data from YouTube. But the channel has a playlist that I don’t want to display, how can I delete it from my function?

searchPlaylists() {
    this.playlists = this.ytProvider.getPlaylistsForChannel(this.channelId);
    this.playlists.subscribe(data => {
      this.found = true;
    }, err => {
      this.found = false;
    })
  }

This is data content

(8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/a1PGkBESaFEOBiuo8ht8waWz7bg"", id: "PL-WHuiw9GA8D0kiMpiqfzmqvVkex_1ySW", snippet: {…}}
1
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/OX5vqTCCMyJYTk-TlL85BGOcc94"", id: "PL-WHuiw9GA8AyFjQReW9UBhDJeiR-lOf4", snippet: {…}}
2
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/pZY_WjywyCaBqVoaWEFtfAiMvOI"", id: "PL-WHuiw9GA8CiydEIiT0ydKN_MPokCX3b", snippet: {…}}
3
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/wlFr2q_M71ofODBvo59k6n0uP3E"", id: "PL-WHuiw9GA8A-Hv9LPQMsYPGSDrDu4ig9", snippet: {…}}
4
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/F504FV2DF7lE1Bftbqg3j-GaJ8w"", id: "PL-WHuiw9GA8CDBJzqvfYCP66jbq2k1hL7", snippet: {…}}
5
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/hsGSpMP1XYOHqQeHVplyrE27E_U"", id: "PL-WHuiw9GA8C53a0oBTNxH3_sa6ixsErC", snippet: {…}}
6
:
{kind: "youtube#playlist", etag: ""_gJQceDMxJ8gP-8T2HLXUoURK8c/6SEWFbyagB6m8Fd30kddp8r4Agw"", id: "PL-WHuiw9GA8D8-ZrFHa7GdngRbQknAsge", snippet: {…}}
length
:
7

I don’t want to display “marcos” playlist.

Is there a way how you can identify, if an entry is marcos playlist? If so, you can use the filter method of the data array.

const filteredData = data.filter(entry => {
  if(/* condition checking if entry is not marcos playlist */) {
    return true;
  }
  return false;
})
3 Likes

Actually, it was way more simple, by adding a pipe in Angular like following

<div *ngFor="let list of playlists | async | slice:1"></div>

That solution removes the first item from your list. But what happens when marcos playlist is not the first item anymore? As soon as the order changes you always have to adjust your slice pipe. But if it always stays the first item that solution is fine.