mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 04:41:03 +00:00
feat: refactor hydra api
This commit is contained in:
@@ -190,6 +190,7 @@ export class HydraApi {
|
||||
await this.revalidateAccessTokenIfExpired();
|
||||
return this.instance
|
||||
.get(url, this.getAxiosConfig())
|
||||
.then((response) => response.data)
|
||||
.catch(this.handleUnauthorizedError);
|
||||
}
|
||||
|
||||
@@ -199,6 +200,7 @@ export class HydraApi {
|
||||
await this.revalidateAccessTokenIfExpired();
|
||||
return this.instance
|
||||
.post(url, data, this.getAxiosConfig())
|
||||
.then((response) => response.data)
|
||||
.catch(this.handleUnauthorizedError);
|
||||
}
|
||||
|
||||
@@ -208,6 +210,7 @@ export class HydraApi {
|
||||
await this.revalidateAccessTokenIfExpired();
|
||||
return this.instance
|
||||
.put(url, data, this.getAxiosConfig())
|
||||
.then((response) => response.data)
|
||||
.catch(this.handleUnauthorizedError);
|
||||
}
|
||||
|
||||
@@ -217,6 +220,7 @@ export class HydraApi {
|
||||
await this.revalidateAccessTokenIfExpired();
|
||||
return this.instance
|
||||
.patch(url, data, this.getAxiosConfig())
|
||||
.then((response) => response.data)
|
||||
.catch(this.handleUnauthorizedError);
|
||||
}
|
||||
|
||||
@@ -226,6 +230,7 @@ export class HydraApi {
|
||||
await this.revalidateAccessTokenIfExpired();
|
||||
return this.instance
|
||||
.delete(url, this.getAxiosConfig())
|
||||
.then((response) => response.data)
|
||||
.catch(this.handleUnauthorizedError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,7 @@ export const createGame = async (game: Game) => {
|
||||
lastTimePlayed: game.lastTimePlayed,
|
||||
})
|
||||
.then((response) => {
|
||||
const {
|
||||
id: remoteId,
|
||||
playTimeInMilliseconds,
|
||||
lastTimePlayed,
|
||||
} = response.data;
|
||||
const { id: remoteId, playTimeInMilliseconds, lastTimePlayed } = response;
|
||||
|
||||
gameRepository.update(
|
||||
{ objectID: game.objectID },
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getSteamAppAsset } from "@main/helpers";
|
||||
export const mergeWithRemoteGames = async () => {
|
||||
return HydraApi.get("/games")
|
||||
.then(async (response) => {
|
||||
for (const game of response.data) {
|
||||
for (const game of response) {
|
||||
const localGame = await gameRepository.findOne({
|
||||
where: {
|
||||
objectID: game.objectId,
|
||||
|
||||
Reference in New Issue
Block a user