Created
July 19, 2022 15:02
-
-
Save trnktms/b9c5702df59e6a89b44ac6ba679a85da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { RestLayoutService, RestLayoutServiceConfig } from '@sitecore-jss/sitecore-jss-nextjs'; | |
interface FetchParams { | |
[param: string]: string | number | boolean; | |
sc_apikey: string; | |
sc_site: string; | |
sc_lang: string; | |
tracking: boolean; | |
} | |
export class ParameterizedRestLayoutService extends RestLayoutService { | |
constructor(private config: RestLayoutServiceConfig) { | |
super(config); | |
} | |
protected getFetchParams = (language?: string): FetchParams => { | |
return { | |
sc_apikey: this.config.apiKey, | |
sc_site: this.config.siteName, | |
sc_lang: language || '', | |
tracking: this.config.tracking ?? true, | |
custom_parameter: '🩹 lorem ipsum', | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment