Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

post-get-service

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

post-get-service - npm Package Compare versions

Comparing version
0.0.4
to
0.0.5
+13
-5
lib/commons/request.js

@@ -9,2 +9,4 @@ /* eslint-disable unicorn/no-object-as-default-parameter */

const default_headers = { 'Content-Type': 'application/json' };
function is_retryable_network_error(err) {

@@ -71,2 +73,3 @@ if (err && err.code) {

* @param {*} headers
* @param {number} [timeout] timeout
* @returns {{

@@ -80,5 +83,6 @@ * host,

* method,
* timeout,
* }}
*/
function prepare_request_opts(url, method, headers = {}) {
function prepare_request_opts(url, method, headers = {}, timeout) {
const { host, port, pathname, protocol, href } = new URL(url);

@@ -96,2 +100,3 @@

method,
timeout,
};

@@ -127,5 +132,6 @@ }

* @param {!{[k: string]: string}} [headers] request headers
* @param {number} [timeout] timeout
*/
async function get(url, headers = { 'Content-Type': 'application/json' }) {
const request_opts = prepare_request_opts(url, 'GET', headers);
async function get(url, headers = { 'Content-Type': 'application/json' }, timeout) {
const request_opts = prepare_request_opts(url, 'GET', headers, timeout);

@@ -144,5 +150,6 @@ const result = await handle_request(request_opts);

* @param {!{[k: string]: string}} [headers] request headers
* @param {number} [timeout] timeout
*/
async function post(url, data, headers = { 'Content-Type': 'application/json' }) {
const request_opts = prepare_request_opts(url, 'POST', headers);
async function post(url, data, headers = { 'Content-Type': 'application/json' }, timeout) {
const request_opts = prepare_request_opts(url, 'POST', headers, timeout);

@@ -161,2 +168,3 @@ const result = await handle_request(request_opts, data);

post,
default_headers,
};
{
"name": "post-get-service",
"version": "0.0.4",
"version": "0.0.5",
"description": "simple way to create node http in memory server",

@@ -5,0 +5,0 @@ "main": "index.js",