# Using api from custom component

**URL:** <https://meta.discourse.org/t/using-api-from-custom-component/304641>\
**Category:** Development\
**Tags:** plugin-api\
**Created:** [April 19, 2024, 4:39pm UTC](https://meta.discourse.org/t/using-api-from-custom-component/304641 "2024-04-19T16:39:33Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![gar1t](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gar1t/32/380142_2.png) [@gar1t](https://meta.discourse.org/u/gar1t)\
**Post date:** [April 19, 2024, 4:39pm UTC](https://meta.discourse.org/t/using-api-from-custom-component/304641/1 "2024-04-19T16:39:33Z")

</div>

I’m trying to access the api from a custom component with this snipped in the html body:

```plaintext
<script type="text/discourse-plugin" version="0.8">
  console.log("###########", api.getCurrentUser());
</script>

```

This snippet however does not appear in the page HTML.

What’s the correct approach here?

Btw, this is the same question posed a few years ago but not answered:

> [@How to insert custom html through jquery using plugin-api events](https://meta.discourse.org/t/how-to-insert-custom-html-through-jquery-using-plugin-api-events/180330):
>
> I have tried to add custom html through jquery using plugin api events like api.onAppEvent(), api.decorateWidget(), etc…, in Edit CSS/HTML \>\> /head section. But, the events which i tried is not triggering the jquery on page load. So, i am little bit confused about what event need to use. Because that event should trigger the jquery throughout the site on page load instead of blocking the scripts on particular pages. Here is the code which i tried,

---

_[View the full topic](https://meta.discourse.org/t/using-api-from-custom-component/304641)._
