Skip to content

Instantly share code, notes, and snippets.

@trnktms
Created July 19, 2022 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trnktms/b9c5702df59e6a89b44ac6ba679a85da to your computer and use it in GitHub Desktop.
Save trnktms/b9c5702df59e6a89b44ac6ba679a85da to your computer and use it in GitHub Desktop.
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