Access App Settings in JavaScript

Hello,
Im a German Developer and currently working on my first NextCloud Application.
I already have a good (and working) base now and wanted to add some Administrator Settings to my App.
I already am at a point where the Value of this single Setting will be saved and loaded in the Settings Page themselves. Because i would need the Value in JavaScript, i tried to access it with

console.log(OCP.AppConfig.getValue('berichtsheft', 'pdf_auto_date', 'no'));

but i just get ‘undefined’ in the console.

I can access the value in PHP but dont know how to use it in JavaScript.

If i try logging

OCP.AppConfig.getValues

without (), then i will see the Function but i cant call it.

Thanks for reading all this and your help.

The OCP prefix is deprecated.

As far as I understand your situation, you have managed to create and access the app’s settings within the PHP backend, right? Now you want to access these from the JS frontend. Am I correct?

Then, you need to provide a backend API endpoint for loadng the current configuration (and one for storing a new configuration) by your backend. The frontend can use @nextcloud/axios to query these endpoints and request the configuration as needed.

Without further information (e.g. a GitHub link) it is hard to help you further.

That’s right.

The way you do it, is by using IInitialState in your ISettings class in php to pass your configs. You can take a look at Port admin settings to vue by CarlSchwan · Pull Request #1880 · nextcloud/news · GitHub to get an idea how this is done in practive and using all the latest vue components