1.0.16 • Published 3 years ago
softweb-poster v1.0.16
Poster
poster is a node module for fetching and posting data
Installation
Use the package manager npm to install softweb-poster.
npm install softweb-poster
Usage
Require
const Poster = require("softweb-poster");
static async importData(params , cb)
- @param {Number} params.port The port the app is running at
- @param {string} params.method The method for the import
- @param {string} params.dateStart the dateStart of the import
- @param {string} params.dateEnd the dateEnd of the import
- @param {string} params.secret the secret of the target url
- @param {number} params.page the page of the pagination
- @param {number} params.pageSize the pageSize of the pagination
- @param {'yes'|'no'} params.state the state of the import
- @param {string} params.target_url the url target
- @callback (error, results) Import result
const Poster = require("softweb-poster");
Poster.importData({port: port , target_url: target_url, method: method, namespace : namespace, dateStart : timeStart, dateEnd : timeEnd, secret : secret, page : page, pageSize : pageSize, state : set_state}, (importErr, importRes) => {
if (importErr !== null) {
res.status(500).send(importErr);
} else {
res.status(200).send(importRes);
}
});
static async getData(params , url , encoding , encoder , timeout)
- @param {JSON} params The endpoint parameters
- @param {String} url The url of the endpoint
- @param {Boolean} encoding Whether you like to encode the results
- @param {String} encoder Encoding format (default UTF-8)
- @param {Number} timeout Whether you like to specify timeout
- @returns {JSON}
- @summary Fetches data from endpoint in binary stream
const Poster = require("softweb-poster");
const data = Poster.getData(params , url , true);