@zcatalyst/smartbrowz
v0.0.3
Published
JavaScript SDK for Catalyst SmartBrowz - PDF, Screenshot, and Dataverse APIs
Maintainers
Readme
@zcatalyst/smartbrowz
JavaScript SDK for Catalyst SmartBrowz - PDF, Screenshot, and Dataverse APIs
Overview
The @zcatalyst/smartbrowz package provides JavaScript/TypeScript methods to access Catalyst SmartBrowz for PDF conversion, screenshots, template generation, and Dataverse lookups. Runs in Node.js (server-side) environments only.
Prerequisites
- A Catalyst project set up
- Understanding of SmartBrowz operations
- Valid URLs or HTML content for processing
Installation
To install this package, simply type add or install @zcatalyst/smartbrowz using your favorite package manager:
npm install @zcatalyst/smartbrowzyarn add @zcatalyst/smartbrowzpnpm add @zcatalyst/smartbrowz
Getting Started
Import
The Catalyst SDK is modularized by Components.
To send a request, you only need to import the Smartbrowz:
// ES5 example
const { Smartbrowz } = require("@zcatalyst/smartbrowz");// ES6+ example
import { Smartbrowz } from "@zcatalyst/smartbrowz";Usage
To send a request, you:
- Create a Smartbrowz Instance.
- Call the Smartbrowz operation with input parameters.
const smartbrowz = new Smartbrowz();
const data = await smartbrowz.convertToPdf("Hey, please convert this to a PDF.");Async/await
We recommend using await operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const smartbrowz = new Smartbrowz();
const data = await smartbrowz.convertToPdf("Hey, please convert this to a PDF.");
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}Error Handling
try {
const data = await smartbrowz.convertToPdf("Hey, please convert this to a PDF.");
// process data.
} catch (error) {
const message = error.message;
const status = error.statusCode;
console.log({ message, status });
}Resources
Contributing
See CONTRIBUTING for more information on how to get started.
License
This SDK is distributed under the Apache License 2.0. See LICENSE file for more information.
