@sryden/matrix
v1.0.0
Published
Matrix is a Node.js module for HTTP GET and POST requests within SRYDEN products.
Downloads
3
Readme
SRYDEN Matrix
Matrix is a Node.js module for HTTP GET and POST requests within SRYDEN products.
Installation
Install Matrix using npm:
npm install @sryden/matrix
Usage
const Matrix = require('@sryden/matrix');
const request = Matrix();
// Example GET request
request.get({
url: 'https://example.com',
})
.then((response) => {
console.log('GET response:', response);
})
.catch((error) => {
console.error('GET error:', error.message);
});
// Example POST request
request.post({
url: 'https://example.com',
data: { title: '1', body: '2', userId: 1 },
})
.then((response) => {
console.log('POST response:', response);
})
.catch((error) => {
console.error('POST error:', error.message);
});
Request
matrix(config)
Creates a new instance of the SRYDEN Matrix module.
config
(optional): Configuration object for the Matrix instance.
get(options)
Performs an HTTP GET request.
options
: Object with the following properties:url
(required): The URL for the GET request.params
(optional): Query parameters for the request.
post(options)
Performs an HTTP POST request.
options
: Object with the following properties:url
(required): The URL for the POST request.data
(optional): Data to be sent in the request body.config
(optional): Additional configuration for the request.