JS API Documentation
Learn how to use the Wized JavaScript API. Our API allows you to build on top of core features — so that you can create additional functionality, that's not possible with Wized alone.
To use the Wized JavaScript API, you need to make sure that Wized have been loaded and initialised on the page. Otherwise you might get an error message similar to "Wized is not defined" or "Wized. ... is not a function" in the console.
To ensure this Wized has been loaded, add an on load wrapper around your Wized JS API code.
You can use this everywhere inside the <body>:
1
window.onload = async () => {
2
// Your Wized JS Code
3
};
Use this method to the value of some data in the data store:
1
window.onload = async () => {
2
const value = await Wized.data.get("r.2.d[0].name"); // Returns the value of "r.2.d[0].name"
3
}
1
window.onload = async () => {
2
const dataStore = await Wized.data.getAll(); // Returns a snapshot of the full data store
3
}
1
window.onload = async () => {
2
Wized.data.listen("v.myvalue", async () => {
3
const newValue = await Wized.data.get("v.myvalue"); // Get new value
4
console.log("Value of v.myvalue changed to: ", newValue); // Console log new value
5
});
6
}
1
window.onload = async () => { await Wized.data.setVariable("username", "Maria"); // Set value of "v.username"
2
const value = await Wized.data.get("v.username"); // Get updated value => "Maria"
3
console.log("Value of v.username changed to: ", value); // Console log updated value
4
}
1
window.onload = async () => {
2
await Wized.data.setCookie("accesstoken", "123ioj3khk324143124"); // Set value of "c.accesstoken"
3
const value = await Wized.data.get("c.accesstoken"); // Get updated value => "123ioj3khk324143124"
4
console.log("Value of c.accesstoken changed to: ", value); // Console log updated value
5
};
1
window.onload = async () => {
2
await Wized.request.execute("Load todos"); // Trigger request
3
const response = await Wized.data.get("r.3.d"); // Get request response
4
console.log(response); // Console log received request data
5
};
1
window.onload = async () => {
2
Wized.request.await("Load todos", (response) => {
3
console.log(response); // Log request response
4
})
5
};
1
window.onload = async () => {
2
Wized.request.awaitAllPageLoad(async () => {
3
const dataStore = await Wized.data.getAll();
4
console.log(dataStore); // Console log the datastore snapshot
5
});
6
};
Last modified 2mo ago