More relaxed parsing of api url, fix race condition when putting heartbeats back into queue

This commit is contained in:
Alan Hamlett
2024-10-08 20:11:28 +02:00
parent 7aff50fd56
commit 703a5f2901
4 changed files with 76 additions and 27 deletions

View File

@@ -3,6 +3,7 @@ import axios, { AxiosResponse } from 'axios';
import browser from 'webextension-polyfill';
import config from '../config/config';
import { CurrentUser, User, UserPayload } from '../types/user';
import { getApiUrl } from '../utils/user';
interface setUserAction {
payload: User | undefined;
@@ -16,11 +17,11 @@ export const fetchCurrentUser = createAsyncThunk<User, string>(
`[${name}]`,
async (api_key = '') => {
const items = await browser.storage.sync.get({
apiUrl: config.apiUrl,
currentUserApiEndPoint: config.currentUserApiEndPoint,
});
const apiUrl = await getApiUrl();
const userPayload: AxiosResponse<UserPayload> = await axios.get(
`${items.apiUrl}${items.currentUserApiEndPoint}`,
`${apiUrl}${items.currentUserApiEndPoint}`,
{
params: { api_key },
},