z-simple-request

1.0.5 • Public • Published

z-simple-request

Install

    npm install z-simple-request --save

Example

    const {request} =require('z-simple-request');
    const req=request('www.google.com',true);
    req({
      method:'get',
      path:'/'
    })
    .then(result=>console.log(result))
    .catch(err=>console.log(err))

API

request

request(hostname,isHttps,opts):req

  • opts
    • port Set initial port of remote server (default 80 | 443)
    • cookie Cookie

req

req(opts,headers):Promise

  • opts
    • method Http method
    • path
    • body Request PayLoad
    • port? Specify a port to override the initial port
    • hostname? Specify a hostname to override
  • headers

    Request http headers

Advanced Example:

const {request}=require('z-simple-request');
const cookie='account=aa';
const req=request('www.xxxx.com',true,{cookie});
req({
 method:'post',
 path:'/submitForm',
 body:{content:'content'}
}).then(....);

//specify a apecial cookie:

const childCookie='account=cc; age=20';

req(
 {
     method:'post',
     path:'/submitForm',
     body:{content:'content'}
 },
 {   
     Cookie:childCookie,
     selfHeader:'xxx'
 }
).then(...);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.50latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.50
1.0.40
1.0.30
1.0.10
1.0.00

Package Sidebar

Install

npm i z-simple-request

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

3.52 kB

Total Files

3

Last publish

Collaborators

  • zhantewei