Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setup() {
// construct the apisauce instance
this.apisauce = create({
baseURL: this.config.url,
timeout: this.config.timeout,
headers: {
Accept: "application/vnd.github.v3+json",
},
})
}
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();
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 {
const createGeoAPI = () => {
const api = create({
baseURL: 'https://ipinfo.io',
credentials: 'omit',
});
const getGeoLocation = () => api.get('');
return {
getGeoLocation,
};
};
export default createGeoAPI();
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);
}
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 };
export function getInvitesForCharacter(shard: number, characterID: string) {
return create(createOptions()).call('groups/getInvitesForCharacter', {
shardID: shard,
characterID: characterID
})
}
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 }
}