Skip to content

Commit

Permalink
fix: login over api-eu leads to redirect to api-de
Browse files Browse the repository at this point in the history
  • Loading branch information
khskekec committed Jul 14, 2022
1 parent 91a2e9f commit 2f02ce9
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GraphData } from './types/graph';
import { LoginResponse } from './types/login';
import { mapData, trendMap } from './utils';

const LIBRE_LINK_SERVER = 'https://api-eu.libreview.io';
const LIBRE_LINK_SERVER = 'https://api.libreview.io';

type ClientArgs = {
username: string;
Expand Down Expand Up @@ -74,15 +74,15 @@ export const LibreLinkUpClient = ({

const loginWrapper =
<Return>(func: () => Promise<Return>) =>
async (): Promise<Return> => {
try {
if (!jwtToken) await login();
return func();
} catch (e) {
await login();
return func();
}
};
async (): Promise<Return> => {
try {
if (!jwtToken) await login();
return func();
} catch (e) {
await login();
return func();
}
};

const getConnections = loginWrapper<ConnectionsResponse>(async () => {
const response = await instance.get<ConnectionsResponse>(
Expand Down Expand Up @@ -171,19 +171,19 @@ export const LibreLinkUpClient = ({
);
const averageTrend =
trendMap[
parseInt(
(
Math.round(
(memValues.reduce(
(acc, cur) => acc + trendMap.indexOf(cur.trend),
0
) /
amount) *
100
) / 100
).toFixed(0),
10
)
parseInt(
(
Math.round(
(memValues.reduce(
(acc, cur) => acc + trendMap.indexOf(cur.trend),
0
) /
amount) *
100
) / 100
).toFixed(0),
10
)
];

mem = new Map();
Expand Down

0 comments on commit 2f02ce9

Please sign in to comment.