UNPKG

1.14 kBMarkdownView Raw
1# request-light
2
3
4[![npm Package](https://img.shields.io/npm/v/request-light.svg?style=flat-square)](https://www.npmjs.org/package/request-light)
5[![NPM Downloads](https://img.shields.io/npm/dm/request-light.svg)](https://npmjs.org/package/request-light)
6[![Build Status](https://github.com/microsoft/node-request-light/workflows/Tests/badge.svg)](https://github.com/microsoft/node-request-light/workflows/Tests)
7[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
9A lightweight request library intended to be used by VSCode extensions.
10- NodeJS and browser main entry points
11- proxy support: Use `configure` or `HTTP_PROXY` and `HTTPS_PROXY` env variables to configure the HTTP proxy addresses.
12
13```ts
14import { xhr, XHRResponse, getErrorStatusDescription } from 'request-light';
15
16const headers = { 'Accept-Encoding': 'gzip, deflate' };
17return xhr({ url: url, followRedirects: 5, headers }).then(response => {
18 return response.responseText;
19}, (error: XHRResponse) => {
20 throw new Error(error.responseText || getErrorStatusDescription(error.status) || error.toString());
21});
22```