# CMS Element Config Daten in main.js abrufen

**URL:** <https://forum.shopware.com/t/cms-element-config-daten-in-main-js-abrufen/71686>\
**Category:** Programmierung\
**Created:** [21. Dezember 2020 um 09:33 UTC](https://forum.shopware.com/t/cms-element-config-daten-in-main-js-abrufen/71686 "2020-12-21T09:33:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f0dg3t](https://avatars.discourse-cdn.com/v4/letter/f/6f9a4e/32.png) [@f0dg3t](https://forum.shopware.com/u/f0dg3t)\
**Post date:** [21. Dezember 2020 um 09:33 UTC](https://forum.shopware.com/t/cms-element-config-daten-in-main-js-abrufen/71686/1 "2020-12-21T09:33:23Z")

</div>

Hi zusammen,

ich habe in meinem Theme einen neuen CMS Block mit custom CMS Element für shopping experiences erstellt. In der Konfiguration von diesem Element in der Administration kann man einen API-Schlussel eingeben. Ich möchte nun in meiner main.js die API Request mit diesem Schlüssel durchführen um die Response in der Storefront auszugeben.

Aber wie komme ich an den in der Config eingegebenen Schlüssel ran? Im Twig-Template kann ich ja easy&nbsp;{{ element.config.apiKey.value }} verwenden, aber da kann ich die API Request nicht ausführen. Wie komme ich an die Config Values in der main.js?

Oder gibt es einen besseren Ansatz als die Request in der main.js vom Theme zu machen? Ich bin für alle Vorschläge offen!

Danke im Voraus!

---

<div class="post-metadata">

**Author:** ![ShapeAndShift](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@ShapeAndShift](https://forum.shopware.com/u/ShapeAndShift)\
**Post date:** [4. Januar 2021 um 09:09 UTC](https://forum.shopware.com/t/cms-element-config-daten-in-main-js-abrufen/71686/2 "2021-01-04T09:09:45Z")

</div>

Über den [systemCofnigApiService](https://github.com/shopware/platform/blob/60ad409864d462b640c77f7206aa78fbd4e3dd23/src/Administration/Resources/app/administration/src/core/service/api/system-config.api.service.js#L4)

Beispiel:&nbsp;[shopware-esd/index.js at master · Shape-and-Shift/shopware-esd · GitHub](https://github.com/Shape-and-Shift/shopware-esd/blob/master/src/Resources/app/administration/src/module/sas-esd/page/sw-product-detail/index.js#L68-L72)

PS: Ah, du willst den in der Storefront bekommen und an dein Storefront JS übergeben? Dafür nutzt die die data-options

Beispiel:&nbsp;[shopware-maps/cms-element-maps.html.twig at master · Shape-and-Shift/shopware-maps · GitHub](https://github.com/Shape-and-Shift/shopware-maps/blob/master/src/Resources/views/storefront/element/cms-element-maps.html.twig)

Und im JS Storefront Plugin holst du dir das data-attr value&nbsp;-\>&nbsp;[shopware-maps/sas-maps.plugin.js at master · Shape-and-Shift/shopware-maps · GitHub](https://github.com/Shape-and-Shift/shopware-maps/blob/master/src/Resources/app/storefront/src/sas-maps/sas-maps.plugin.js#L18)

Oder sauberer direkt über die Options -\>&nbsp;[Shopware 6: Write your own storefront JavaScript plugin](https://docs.shopware.com/en/shopware-platform-dev-en/how-to/js-storefront-plugin?category=shopware-platform-dev-en/how-to#configuring-your-plugins)
