# YouTube Example(APIs)

**URL:** <https://discourse.mozilla.org/t/youtube-example-apis/98264>\
**Category:** Learn\
**Created:** [June 11, 2022, 10:20am UTC](https://discourse.mozilla.org/t/youtube-example-apis/98264 "2022-06-11T10:20:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![owolagbadavid](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/owolagbadavid/32/39693_2.png) [@owolagbadavid](https://discourse.mozilla.org/u/owolagbadavid)\
**Post date:** [June 11, 2022, 10:20am UTC](https://discourse.mozilla.org/t/youtube-example-apis/98264/1 "2022-06-11T10:20:30Z")

</div>

In the [YouTube Example](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Third_party_APIs#youtube_example) on Third-party APIs `section.removeChild(e.target.a);` does not remove the the unplayable YouTube videos, it throws an error in the console.

When I was trying to debug the issue, I created a variable and assigned the last unplayable video to it.

`let mike = "";`  
.  
.  
`//The event handler that grabs the ID of each video, and checks its duration`

```
  if (duration === 0) {
    console.log(`Video ${myId} cannot be played, so it was deleted.`);
  mike = e.target;
section.removeChild(e.target.a) //throws an error
}

```

I examined the different properties of target `"YT.Player"` object i.e `"mike"`  
`mike.a` OR `(e.target.a)` was undefined.  
I discovered `mike` had a property `mike.i` (refers to the YouTube iframe), so I changed [e.target.a to e.target.i](https://github.com/mdn/learning-area/pull/505) and it removed the unplayable videos.

---

<div class="post-metadata">

**Author:** ![schalkneethling](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/schalkneethling/32/22691_2.png) [@schalkneethling](https://discourse.mozilla.org/u/schalkneethling)\
**Post date:** [June 13, 2022, 2:19pm UTC](https://discourse.mozilla.org/t/youtube-example-apis/98264/2 "2022-06-13T14:19:28Z")

</div>

Hey there @owolagbadavid,

Thank you for digging into this. Could you point me to a running version of your code? Also, if you believe there is an error in the MDN Web Docs page you linked to, please let us know by filing an issue using the “Report a problem…” link at the bottom of the page. Thank you.

–  
Schalk  
Staff Community Manager - MDN Web Docs

---

<div class="post-metadata">

**Author:** ![owolagbadavid](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/owolagbadavid/32/39693_2.png) [@owolagbadavid](https://discourse.mozilla.org/u/owolagbadavid)\
**Post date:** [June 13, 2022, 4:47pm UTC](https://discourse.mozilla.org/t/youtube-example-apis/98264/3 "2022-06-13T16:47:52Z")

</div>

This is it [live](https://youtube-api-pied.vercel.app/)  
And there is no error in the MDN Web Docs page just the [source code](https://github.com/mdn/learning-area/blob/main/javascript/apis/third-party-apis/youtube/script.js) for the YouTube API example
