1.2.0 • Published 2 years ago

libgovno v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

install size

  1. Include lib const { requests } = require('libgovno');

Quick example

// Callbacks
requests.get('https://example.com/', (err, data) => { console.log(data.status); });

// Promises
requests.get('https://example.com/')
    .then((err, data) => {
        console.log(data.status);
    });
    
// Async await
const data = await requests.get('https://example.com/');
    
// Passing some data
requests.get('https://example.com/', { json: {'key':'value'} });

// Link params
requests.get('https://example.com/', { params: {'key':'value'} });

// Cookies
requests.get('https://example.com/', { cookies:[ { name:'aboba',value:'yes' } ] });  

Request options

method: string - HTTP request method (GET/POST/etc)

port: string | number - remote http port

params: object - link params https://example.com/?param=1

json: object - json data

raw_data: string | Buffer - raw data buffer

headers: OutgoingHttpHeaders - http headers (Accept, User-Agent, etc)

cookies: Array<object> - cookies in the following format: { name: 'aboba', value: 'yes' }

useragent: string - request useragent

timeout: number - request timeout

follow_redirects: boolean - should we follow location header?

worldwide: boolean - true by default, automatically adds www. to the url

callback: ResponseCallback - response callback (err: Error, data: Response) => {}

Response shortcuts

body: string - response body

text: string - same as body

headers: object - response headers

status: number - response status code

status_code: number - same as status

encoding: string - repsonse content-encoding

cookies: string - response set-cookie header, will become object in new version

redirects: number - count of the http redirects

is_redirect: boolean - returns true if redirects count more than 0

json(): object - parsed json object from body

1.2.0

2 years ago

1.1.9

2 years ago

1.1.81

2 years ago

1.1.80

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago