@directsp/client-js
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

DirectSpClientJs

DirectSp client for JavaScript

Usage

  1. Install by NPM
npm i @directsp/client-js
  1. Create and intialize object
import { directSp } from "../node_modules/@directsp/client-js";

// Creating a global DirectSpClient object
window.dspClient = new directSp.DirectSpClient({
  resourceApiUri: "http:/your_directsp_host_url/api",
  isLogEnabled: true,
  isUseAppErrorHandler: true
});

// Initializing the object
dspClient.init();

// Handle authentication if any
// update this property as soon as your authorization provider gives you a new token
dspClient.authHeader = "a bearer authorization token such as google user token";

3. Invoke procedures

```javascript
// without options
dspClient.invoke("MyMethod", { param1: "value1", param2: "value2" })
  .then(data => {
    console.log(data);
    console.log(data.returnValue);
    console.log(data.outParam1);
    console.log(data.outParam2);
    console.log(data.recordset);
  });

// with options
dspClient.invoke("MyMethod", { param1: "value1", param2: "value2" }, { recordIndex: 0, recordCount: 10 })
  .then(data => {
    console.log(data);
  });

Authentication

You can bypass authentication system by setting auth to null

Runtime API Help

in your browser console just run

dspClient.help()

Readme

Keywords

Package Sidebar

Install

npm i @directsp/client-js

Weekly Downloads

1

Version

2.1.2

License

ISC

Unpacked Size

81.4 kB

Total Files

7

Last publish

Collaborators

  • madnik7