Backend HTTP
Helper module for working with znHttp in Zengine backend Plugins.
Installation
npm i @zenginehq/backend-http
Usage
Bulk fetching records
var $api = require('@zenginehq/backend-http')();
znHttp().get(path)
.then($api.formatResponse)
.then(data => {
})
.catch($api.errHandler);
$api.fetchBatched(path, { limit: 100, 'not-field123': 'some value' })
.then(results => {
console.log(results.length);
});
Record CRUD
$api.getRecord(formId, recordId).then(record => {
});
$api.updateRecord(formId, recordId, data, options, delay);
$api.queryRecords = (formId, options);
$api.deleteRecord(formId, recordId);
$api.createRecord(formId, data).then(recordId => {
});
$api.moveRecord(formId, recordId, folderId);
Special Note
To update multiple records on the same form, use the createRecord
method and include the IDs of each object to ensure they are updated, rather than having new records created.
Other convenience methods
const activity = await $api.getActivity(activityId);
const form = await $api.getForm(formId);
API Docs
Full documentation