Skip to content

maple3142/request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chaining & Immutable node.js request library

Examples:

const api = request('https://example.com/api/').header('Authorization', 'Bearer <token>')

base.get()
	.url('get') // GET /api/get
	.query({ id: 7 }) // GET /api/get?id=7
	.send()
	.then(resp => resp.json())
	.then(json => {
		console.log(json)
	})

base.post()
	.url('img/upload') // POST /api/img/upload
	.form({ // multipart/form-data
		file: fs.readFileSync('./image.png')
	})
	.send()
	.then(resp => resp.json())
	.then(json => {
		console.log(json)
	})

request('https://example.com/logo.png')
	.then(resp => {
		// fetch an image to save it to file using stream
		resp.stream().pipe(fs.createWriteStream('./logo.png'))
	})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published