diff --git a/src/utils/api.js b/src/utils/api.js index 46bf674..72ba96d 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -13,19 +13,26 @@ export default { oauthToken: '', spaceId: null, region: '', + client: null, getClient () { const { region } = creds.get() try { - return new Storyblok({ - accessToken: this.accessToken, - oauthToken: this.oauthToken, - region: this.region, - headers: { - ...DEFAULT_AGENT - } - }, this.apiSwitcher(region)) + if (!this.client) { + this.client = new Storyblok( + { + accessToken: this.accessToken, + oauthToken: this.oauthToken, + region: this.region, + headers: { + ...DEFAULT_AGENT, + }, + }, + this.apiSwitcher(region) + ); + } + return this.client } catch (error) { throw new Error(error) }