Add support for got.extend

This commit is contained in:
Matthew Bull
2019-01-29 22:22:25 +00:00
parent fda6ae2b4f
commit ab5d87f8ef
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -266,6 +266,10 @@ got('/examples/angularjs', { baseUrl: 'http://todomvc.com' });
got('http://todomvc.com', { headers: { foo: 'bar'} });
got('http://todomvc.com', { cookieJar: new tough.CookieJar() });
// Test extension
got.extend({ method: 'POST' })('/example');
got.extend({ method: 'POST' }).extend({ headers: {} }).stream('/example');
// Test retry options.
got('http://todomvc.com', { retry: 2 });
got('http://todomvc.com', {
+2
View File
@@ -4,6 +4,7 @@
// Linus Unnebäck <https://github.com/LinusU>
// Konstantin Ikonnikov <https://github.com/ikokostya>
// Stijn Van Nieuwenhuyse <https://github.com/stijnvn>
// Matthew Bull <https://github.com/wingsbob>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -72,6 +73,7 @@ declare const got: got.GotFn &
Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotFn> &
{
stream: got.GotStreamFn & Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotStreamFn>;
extend: (options: got.GotJSONOptions | got.GotFormOptions<string> | got.GotFormOptions<null> | got.GotBodyOptions<string> | got.GotBodyOptions<null>) => typeof got;
RequestError: typeof RequestError;
ReadError: typeof ReadError;
ParseError: typeof ParseError;