Nosto JS is a wrapper for the client script, providing an easy way to interact with the Nosto service from your JavaScript or TypeScript applications.
For more information about JS API, see Our documentation.
When using this library, it is not necessary to create the Nosto stub. It will be created automatically as soon as the library is imported for the first time.
The init
function will load the latest version of the client script and add it to your page on runtime.
It returns a promise that resolves when the client script is fully loaded and initialized. However, awaiting it is optional.
Use the nostojs
function exported from the library in the same way you would use window.nostojs
. In fact, this is a typed wrapper over the window function.
You may safely use this even before the init
function has been called. Any early calls will be queued and processed later, when the client script is initialized.
Use the mockNostojs
function to mock the Nosto API in unit tests. The function accepts partial API mocks and merges them with default mock API behaviour: