How to use funtch - 6 common examples

To help you get started, we’ve selected a few funtch 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 ViBiOh / dashboard / src / services / Auth / index.js View on Github external
static getGithubAccessToken(state, code) {
    return funtch
      .url(
        `${getAuthApiUrl()}/login/github?state=${encodeURIComponent(
          state,
        )}&code=${encodeURIComponent(code)}`,
      )
      .error(customError)
      .get();
  }
github ViBiOh / dashboard / app / services / Commons / index.js View on Github external
export function auth(url, authentification = localStorage.getItem(STORAGE_KEY_AUTH)) {
  if (!authentification) {
    const authError = new Error('Authentification not find');
    authError.noAuth = true;
    throw authError;
  }

  return funtch.url(url).error(customError).auth(authentification);
}
github ViBiOh / dashboard / src / services / Commons / index.js View on Github external
export function auth(url, authentification = localStorage.getItem(STORAGE_KEY_AUTH)) {
  if (!authentification) {
    const authError = new Error('Authentification not find');
    authError.noAuth = true;
    throw authError;
  }

  return funtch
    .url(url)
    .error(customError)
    .auth(authentification);
}
github ViBiOh / dashboard / src / services / Commons / index.js View on Github external
return new Promise((resolve, reject) =>
    errorHandler(response)
      .then(resolve)
      .catch(err =>
        reject(
          new Error({
            ...err,
            toString: () => {
              if (!err.content && httpErrorMessage[err.status]) {
                return httpErrorMessage[err.status];
              }

              if (typeof err.content === 'string') {
                return err.content;
              }

              return JSON.stringify(err.content);
            },
github ViBiOh / dashboard / app / services / Commons / index.js View on Github external
return new Promise((resolve, reject) =>
    errorHandler(response).then(resolve).catch(err =>
      reject({
        ...err,
        toString: () => {
          if (typeof err.content === 'string') {
            return err.content;
          }
          return JSON.stringify(err.content);
        },
      }),
    ),
  );
github ViBiOh / dashboard / src / Constants.js View on Github external
};

      resolve(context);
    } else if (process.env.NODE_ENV === 'staging') {
      context = {
        API_URL: 'https://dashboard-api.vibioh.fr',
        AUTH_URL: 'https://dashboard-auth.vibioh.fr',
        BASIC_AUTH_ENABLED: 'false',
        ENVIRONMENT: 'dev',
        GITHUB_AUTH_ENABLED: 'true',
        WS_URL: 'wss://dashboard-api.vibioh.fr/ws',
      };

      resolve(context);
    } else {
      funtch.get('/env').then(env => {
        context = env;
        resolve(context);
      });
    }
  });
}

funtch

FUNctional feTCH isomorphic

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis