How to use apisauce - 10 common examples

To help you get started, we’ve selected a few apisauce 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 infinitered / ChainReactApp2019 / app / services / api / api.ts View on Github external
setup() {
    // construct the apisauce instance
    this.apisauce = create({
      baseURL: this.config.url,
      timeout: this.config.timeout,
      headers: {
        Accept: "application/vnd.github.v3+json",
      },
    })
  }
github jake / screenhole-web / src / utils / api.js View on Github external
import { create } from "apisauce";

const apiEndpoint =
  process.env.NODE_ENV === "production" ? "/api" : "https://api.screenhole.net";

const api = create({
  baseURL: apiEndpoint,
  // baseURL: '/api',
  // baseURL: 'https://api.screenhole.net',
  // baseURL: 'https://screenhole-api.ngrok.io',
  // baseURL: "https://staging-api.screenhole.net",
});

api.websocketURL = "wss://api.screenhole.net";
// api.websocketURL = "wss://staging-api.screenhole.net";
// api.websocketURL = 'wss://screenhole-api.ngrok.io';

// reset on 401 API responses
api.addResponseTransform(response => {
  if (!response.ok) {
    if (response.status === 401) {
      api.resetLocalStorage();
github TobiahRex / reactBoilerplate / src / Services / API.js View on Github external
function createAPI() {
  const api = create({
    baseURL: NODE_ENV === 'production' ? DEPLOY_URL : BASE_URL,
    headers: {
      'Cache-Control': 'no-cache',
    },
    credentials: 'omit',
  });

  const getAllThings = () => api.get('api/things/');

  const createThing = ({ name }) => api.post('api/things', { name });

  const removeThing = id => api.delete(`api/things/${id}`);

  const editThing = ({ name, _id }) => api.put(`api/things/${_id}`, { name });

  return {
github TobiahRex / nj2jp / src / services / api / geolocation / index.js View on Github external
const createGeoAPI = () => {
  const api = create({
    baseURL: 'https://ipinfo.io',
    credentials: 'omit',
  });

  const getGeoLocation = () => api.get('');

  return {
    getGeoLocation,
  };
};
export default createGeoAPI();
github csegames / Camelot-Unchained / library / src / webAPI / warbands / warbandsAPI.ts View on Github external
export function inviteCharacterToWarbandByName(shard: number, characterID: string, targetName: string, warbandID: string = '') {
  let params: any = {
    shardID: shard,
    characterID: characterID,
    targetName: targetName
  };
  if (warbandID.length > 0) params.warbandID = warbandID;
  return create(createOptions()).call('groups/inviteCharacterToWarbandByName', params);
}
github ctlabvn / ReactNativeStarterKits / src / store / api / common.js View on Github external
import { create } from 'apisauce';
import { API_TIMEOUT } from '~/constants/api';
import configs from '~/constants/configs';

const API = create({
  baseURL: configs.endPoint,
  timeout: API_TIMEOUT,
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json'
  }
});

export { API };
github csegames / Camelot-Unchained / library / src / webAPI / groups / groupsAPI.ts View on Github external
export function getInvitesForCharacter(shard: number, characterID: string) {
  return create(createOptions()).call('groups/getInvitesForCharacter', {
    shardID: shard,
    characterID: characterID
  })
}
github xiaomuzhu / ReactNativeTS / App / Services / LoginService.ts View on Github external
const LoginApi = (url = loginURL): TopicApi => {
  const api = create({
    baseURL: url,
    headers: {
      'Cache-Control': 'no-cache',
    },
    timeout: 10000,
  })

  const postLoginRequest = (params: LoginInfoParams) => {
    return api.post('login', params)
  }

  return { postLoginRequest }
}

apisauce

Axios + standardized errors + request/response transforms.

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis

Popular apisauce functions