How to use the @sitecore-jss/sitecore-jss-react.dataApi.fetchRouteData function in @sitecore-jss/sitecore-jss-react

To help you get started, we’ve selected a few @sitecore-jss/sitecore-jss-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github altola / sitecore-jss-react-starter / src / src / RouteHandler.js View on Github external
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;
  });
}
github Sitecore / Sitecore.HabitatHome.Omni / fitness / app / src / RouteHandler.js View on Github external
}

  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;
  });
}

@sitecore-jss/sitecore-jss-react

This module is provided as a part of Sitecore JavaScript Rendering SDK (JSS). It contains React components and integration for JSS.

Apache-2.0
Latest version published 7 days ago

Package Health Score

66 / 100
Full package analysis

Similar packages