0.5.5 • Published 5 months ago

remp-node-api v0.5.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

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);
}
0.5.4

6 months ago

0.5.3

6 months ago

0.5.5

5 months ago

0.5.0

6 months ago

0.5.2

6 months ago

0.5.1

6 months ago

0.3.0

2 years ago

0.4.4

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago