From c002aaa97c45fa5dfd91325a005fd5cc18a55b57 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 21 Aug 2020 11:51:38 +0100 Subject: [PATCH] fix(types): add missing types for `create` and `setBaseURL` (#122) * fix: add missing types for `create` and `setBaseURL` * fix: correct `create` return type --- types/index.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/types/index.d.ts b/types/index.d.ts index 30f599f..3e6a053 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -104,6 +104,12 @@ interface NuxtHTTPInstance { $delete(url: Request | URL | string, options?: Options): Promise; + /** + * Set the baseURL for all subsequent requests. + * @param baseURL - the base URL (e.g. `https://myapi.com/`) + */ + setBaseURL(baseURL: string): void + /** * Set a header on all subsequent requests. * @param name - Header name. @@ -146,6 +152,11 @@ interface NuxtHTTPInstance { * This hook enables you to globally handle request errors. */ onError(hook: (error: ky.HTTPError) => void): void + + /** + * If you need to create your own ky instance which based on $http defaults, you can use the create(options) method. + */ + create(options: Partial): NuxtHTTPInstance } declare module '@nuxt/vue-app' {