Skip to content

srcagency/fetch-one

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fetch one

Very opinionated one-function package for doing HTTP requests from Node.js (using request) and the browser if you're using something compatible with Browserify.

Returning (bluebird) promises resolving to a response object (read source for details) having code, mesage, headers and body properties. If the code is not in the 200 range, the response will be thrown instead.

var fetch = require('fetch-one');

fetch('GET', 'https://google.com', { q: 'peace' }, {
	'X-Progress': 'Half way there'
});

fetch('POST', 'http://example', {
	field: 'value',
	nested: {
		field: 'value',
	},
})

I just needed something simple that worked in both environments and without a lot of bells and whistles. It is probably inadequate for most other use cases than mine.

I hope it will some day be replaced by a "universal" version of the new fetch API.

About

Minimal universal request helper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published