http
Promise based HTTP client for node.js
Install
$ npm i node-request-promise
Useage
const http = ;const assert = ; async { // http const httpRes = await http; ; // https const httpsRes = await http; ; // download file: use pipe const fs = ; const res = await http res // or use pipeline const stream = ; const util = ; const pipeline = util; const res = await http; await ; // post Buffer const res = await http; ; // post Stream const fs = ; const readStream = fs; const res = await http; ; // post json const data = username: 'zfx' password: 'password' ; const res = await http; ; // post application/x-www-form-urlencoded const data = username: 'zfx' password: 'password' ; const options = headers: 'Content-Type': 'application/x-www-form-urlencoded' ; const res = await http; ; // post FormData const FormData = ; const form = ; const fs = ; const readStream = fs; form; form; form; // Set filename by providing a string for options form; // provide an object. form; const formHeaders = form; const res = await http; ; // head const res = await http; ; ; ; ; ; // options const res = await httpoptionsurl; ; };
More examples in the test
folder.
Type definitions
;; declare ; ;
test
$ cd ./test$ node test