Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getRouteData(route, language) {
const fetchOptions = {
layoutServiceConfig: { host: config.sitecoreApiHost },
querystringParams: { sc_lang: language, sc_apikey: config.sitecoreApiKey },
fetcher: dataFetcher,
};
return dataApi.fetchRouteData(route, fetchOptions).catch((error) => {
if (error.response && error.response.status === 404 && error.response.data) {
return error.response.data;
}
console.error('Route data fetch error', error, error.response);
return null;
});
}
}
const systemQueryParams = {
sc_lang: language,
sc_apikey: config.sitecoreApiKey
};
const queryParams = Object.assign(currentUrlParams, systemQueryParams);
const fetchOptions = {
layoutServiceConfig: { host: config.sitecoreApiHost },
querystringParams: queryParams,
requestConfig: options,
fetcher: dataFetcher
};
return dataApi.fetchRouteData(route, fetchOptions).catch((error) => {
if (error.response && error.response.status === 404 && error.response.data) {
return error.response.data;
}
console.error('Route data fetch error', error, error.response);
return null;
});
}