I think it would be cool if there was an easy way to do something like:
var github = got.endpoint('https://api.github.com', {agent: ...});
// github has the same API as got, except you don't need the base path
// and certain default options (i.e. `agent`) are already defined
github('/foo', {});
This main advantage would be for testing:
function MyGitHubApi() {
this._gh = got.endpoint('https://api.github.com', {agent: ...});
}
MyGitHubApi.getFoo = function () {
return this._gh('/foo');
}
// later in tests:
var api = new MyGitHubApi();
api._gh.override('http://localhost:3000');
We have a lot of files, that just export got with default values. I would love to see a package got-api with some sweet stuff for generating cool API wrappers.
Ability to add new options would be cool too.
Here it comes: #503
Most helpful comment
We have a lot of files, that just export
gotwith default values. I would love to see a packagegot-apiwith some sweet stuff for generating cool API wrappers.