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