From 28002a23d1934d77311b8014eab726d3f5957128 Mon Sep 17 00:00:00 2001 From: Mitch Ryan Date: Tue, 25 Jun 2024 15:03:05 +0200 Subject: [PATCH 1/2] Make "params" argument optional in getter methods --- src/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index a4749ee0..6f0e89db 100755 --- a/src/index.ts +++ b/src/index.ts @@ -225,7 +225,7 @@ class Storyblok { public get( slug: string, - params?: ISbStoriesParams, + params: ISbStoriesParams = {}, fetchOptions?: ISbCustomFetch ): Promise { if (!params) params = {} as ISbStoriesParams @@ -237,7 +237,7 @@ class Storyblok { public async getAll( slug: string, - params: ISbStoriesParams, + params: ISbStoriesParams = {}, entity?: string, fetchOptions?: ISbCustomFetch ): Promise { @@ -270,7 +270,7 @@ class Storyblok { public post( slug: string, - params: ISbStoriesParams | ISbContentMangmntAPI, + params: ISbStoriesParams | ISbContentMangmntAPI = {}, fetchOptions?: ISbCustomFetch ): Promise { const url = `/${slug}` @@ -280,7 +280,7 @@ class Storyblok { public put( slug: string, - params: ISbStoriesParams | ISbContentMangmntAPI, + params: ISbStoriesParams | ISbContentMangmntAPI = {}, fetchOptions?: ISbCustomFetch ): Promise { const url = `/${slug}` @@ -290,7 +290,7 @@ class Storyblok { public delete( slug: string, - params: ISbStoriesParams | ISbContentMangmntAPI, + params: ISbStoriesParams | ISbContentMangmntAPI = {}, fetchOptions?: ISbCustomFetch ): Promise { const url = `/${slug}` @@ -299,7 +299,7 @@ class Storyblok { } public getStories( - params: ISbStoriesParams, + params: ISbStoriesParams = {}, fetchOptions?: ISbCustomFetch ): Promise { this._addResolveLevel(params) @@ -309,7 +309,7 @@ class Storyblok { public getStory( slug: string, - params: ISbStoryParams, + params: ISbStoryParams = {}, fetchOptions?: ISbCustomFetch ): Promise { this._addResolveLevel(params) From c1681dc2f4bd02f759a7d50ad711dba6ca16795e Mon Sep 17 00:00:00 2001 From: Mitch Ryan Date: Mon, 8 Jul 2024 13:55:20 +0200 Subject: [PATCH 2/2] Remove redundant params reassignment --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 6f0e89db..b96a53b1 100755 --- a/src/index.ts +++ b/src/index.ts @@ -228,7 +228,6 @@ class Storyblok { params: ISbStoriesParams = {}, fetchOptions?: ISbCustomFetch ): Promise { - if (!params) params = {} as ISbStoriesParams const url = `/${slug}` const query = this.factoryParamOptions(url, params)