Minimalist HTTP request, Only dependency iconv-lite
.
npm i @junyiz/request
You will need iconv-lite
const request = require('@junyiz/request');
(async () => {
const repo = await request({
url: 'https://api.github.com/repos/junyiz/request',
json: true,
headers: { 'User-Agent': '@junyiz/request' }
});
console.log('repos id: ' + repo.id + ' repos name: ' + repo.full_name);
})();
Type: String
Type: String
Default: ''
Type: Boolean
Default: false
Parse response body with JSON.parse
.
Type: Object
Default: {}
Type: String
Default: GET
Type: Number
Default: 60 * 1000
Milliseconds to wait for a server to send response headers before aborting request with ETIMEDOUT
error.
Type: Number
Default: 2
Type: string
Default: 'utf8'
Type: http(s).Agent
Copyright (c) 2018-2019 junyiz. Licensed under the MIT license.