Simple Kinvey Get Data
HTML
<script src="https://da189i1jfloii.cloudfront.net/js/kinvey-html5-sdk-3.10.2.min.js"></script>
<div id="allRegions">
</div>
JavaScript
const client = Kinvey.init({
appKey: 'kid_SkbG2i0hW',
appSecret: 'dff4c87cbcd544ee9e9d9a79123097d4'
});
const activeUser = Kinvey.User.getActiveUser(client);
function loadDataStore() {
const dataStore = Kinvey.DataStore.collection('shrines');
const stream = dataStore.find();
stream.subscribe(
(regions) => {
const el = document.getElementById('allRegions');
regions.forEach((region) => {
el.innerHTML += `<p>${region.name}</p>`;
});
},
(error) => {
console.log(error);
}
);
}
if (!activeUser) {
Kinvey.User.signup()
.then(() => {
loadDataStore();
})
.catch((error) => {
console.log(error);
});
} else {
loadDataStore();
}