mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: catch hltb error
This commit is contained in:
parent
567d9f540d
commit
158b878883
1 changed files with 21 additions and 15 deletions
|
@ -2,6 +2,7 @@ import axios from "axios";
|
||||||
import { requestWebPage } from "@main/helpers";
|
import { requestWebPage } from "@main/helpers";
|
||||||
import { HowLongToBeatCategory } from "@types";
|
import { HowLongToBeatCategory } from "@types";
|
||||||
import { formatName } from "@shared";
|
import { formatName } from "@shared";
|
||||||
|
import { logger } from "./logger";
|
||||||
|
|
||||||
export interface HowLongToBeatResult {
|
export interface HowLongToBeatResult {
|
||||||
game_id: number;
|
game_id: number;
|
||||||
|
@ -13,7 +14,8 @@ export interface HowLongToBeatSearchResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const searchHowLongToBeat = async (gameName: string) => {
|
export const searchHowLongToBeat = async (gameName: string) => {
|
||||||
const response = await axios.post(
|
const response = await axios
|
||||||
|
.post(
|
||||||
"https://howlongtobeat.com/api/search",
|
"https://howlongtobeat.com/api/search",
|
||||||
{
|
{
|
||||||
searchType: "games",
|
searchType: "games",
|
||||||
|
@ -28,7 +30,11 @@ export const searchHowLongToBeat = async (gameName: string) => {
|
||||||
Referer: "https://howlongtobeat.com/",
|
Referer: "https://howlongtobeat.com/",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
.catch((error) => {
|
||||||
|
logger.error("Error searching HowLongToBeat:", error?.response?.status);
|
||||||
|
return { data: { data: [] } };
|
||||||
|
});
|
||||||
|
|
||||||
return response.data as HowLongToBeatSearchResponse;
|
return response.data as HowLongToBeatSearchResponse;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue