export async function fetchDataForRouteEnter()

in src/utils/data.js [59:86]


export async function fetchDataForRouteEnter(to, from, next) {
  const path = createDataPath(to.path);

  let data;
  try {
    data = await fetchData(path, to.query);
  } catch (error) {
    if (process.env.VUE_APP_TARGET === 'ide') {
      console.error(error);
      // We need to throw false to pass false to the following `catch` function
      // so we stop the navigation by calling `next(false)`
      /* eslint-disable no-throw-literal */
      throw false;
    }

    if (error.status && error.status === 404) {
      // route to 404 page if missing data, but not in IDE build
      next({
        name: 'not-found',
        params: [to.path],
      });
    } else {
      next(new FetchError(to));
    }
  }

  return data;
}