Skip to content

alexmerz/remp-node-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: '[email protected]'
}
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: '[email protected]',
    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);
}

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published