remp-node-api

0.5.5 • Public • Published

remp-node-api

Thin wrapper around the REMP server API for Node.js.

This package nor the author are related in any way with Remp or Dennikn.sk.

How to use this package?

Install the package via your favourite node.js package manager.

In general you, set up a Remp instance with your server URL and the API bearer token, then you call get() or post() of that instance with the API URL path and the parameters. The result is the JSON reponse already decoded into a plain old JS object.

const {Remp} = require('remp-node-api')

const options = {
    server: 'https://crm.press/',
    token: '...',
    referer: 'https://example.com/',
    verbose: true, // show debug messages on console
    customHeaders: { // optional
        // set custom headers or overwrite defaults
        'Content-Type': 'application/json'
    }
}

const remp = new Remp(options);

const params = {
    Email: 'example@example.com'
}
const result = await remp.get('api/v1/users/email', params);
console.log(result);

Special handling for user access tokens

If a API call returns an access token in its response, you can easily create a new remp instance with that token.

const {Remp, RempUser, RempUsers} = require('remp-node-api')

const options = {
    server: 'https://crm.press/',
    token: '...',
    referer: 'https://example.com/'
}

const remp = new Remp(options);
const rempusers = new RempUsers(remp);
let myuser = null;

const params = {
    Email: 'example@example.com',
    Password: 'secret'
}
const loginresult = await rempusers.login(params)
if(remp.hasNewToken()) {
    myuser = remp.createTokenInstance();
}

if(myuser !== null) {
    const userdata = await myuser.info();
    console.log(userdata);
}

Readme

Keywords

none

Package Sidebar

Install

npm i remp-node-api

Weekly Downloads

5

Version

0.5.5

License

Apache-2.0

Unpacked Size

30.7 kB

Total Files

10

Last publish

Collaborators

  • alexmerz
  • soeren-g
  • early_earl