Are there any code samples where the TypeScript SDK is used without a javascript framework?
I’m looking for an absolute minimal example of how to authenticate and run a query in vanilla typescript (or JS).
The documentation is sparse when it comes to this and all code examples I’ve found rely on React.
My goal is to use the TypeScript SDK in a vue project, but in order to do that I need to first understand how it works.
You can check here about use it in Vue with npm.
And, you can use sdk:all
option to generate models, enumerations, and APIs for TS.
Hi @drew,
In addition, once you’ve generated the TypeScript SDK as described above by @hanbing.yin, you will need CUBA REST JS library. First, create a CubaApp
instance by using initializeApp function. If your web-app.properties
contains client id and secret you’ll need to pass them to this method. Also you might need to pass the base URL of the REST API endpoint via apiUrl
.
Then, login by using the login method. Check the CUBA REST JS API Reference for other methods you might be interested in. Specifically, to query a list of entities you’ll want to use loadEntities
or loadEntitiesWithCount
. If you want to use filters (i.e. search condition) - go for searchEntities
and searchEntitiesWithCount
.
I cannot give any Vue-specific advice, but the above should work regardless of the framework or in vanilla JS.
I’ve created a ticket to add more detailed documentation covering this use case.