We
Getting started with WeDeploy Data on the web
Add API Methods
Save Data
Now we want to add a script that will save data to a collection.
To do this, go to data-web-tutorial/ui/index.js
and paste this code:
WeDeploy
.data('db-.wedeploy.io')
.create('tasks', {name: form.item.value })
.then(function(response) {
form.reset();
form.item.focus();
console.info('Saved:', response);
})
.catch(function(error) {
console.error(error);
});
Note: make sure to replace
with the id of your project.
Fetch Data
Next, we want to add a script that will fetch data from the collection.
To do this, go to list.js
inside of the same folder and paste this code:
WeDeploy
.data('db-.wedeploy.io')
.orderBy('id', 'desc')
.limit(5)
.get('tasks')
.then(function(response) {
appendTasks(response);
})
.catch(function(error) {
console.error(error);
});
Note: make sure to replace
with the id of your project.