Fixed bug when API key is missing

This commit is contained in:
ltctceplrm 2024-08-22 00:22:56 +02:00
parent 265bf10426
commit 552e921d53
2 changed files with 6 additions and 4 deletions

View file

@ -22,7 +22,8 @@ export class MobyGamesAPI extends APIModel {
console.log(`MDB | api "${this.apiName}" queried by Title`); console.log(`MDB | api "${this.apiName}" queried by Title`);
if (!this.plugin.settings.MobyGamesKey) { if (!this.plugin.settings.MobyGamesKey) {
throw Error(`MDB | API key for ${this.apiName} missing.`); console.error(Error(`MDB | API key for ${this.apiName} missing.`));
return [];
} }
const searchUrl = `${this.apiUrl}/games?title=${encodeURIComponent(title)}&api_key=${this.plugin.settings.MobyGamesKey}`; const searchUrl = `${this.apiUrl}/games?title=${encodeURIComponent(title)}&api_key=${this.plugin.settings.MobyGamesKey}`;
@ -65,7 +66,7 @@ export class MobyGamesAPI extends APIModel {
console.log(`MDB | api "${this.apiName}" queried by ID`); console.log(`MDB | api "${this.apiName}" queried by ID`);
if (!this.plugin.settings.MobyGamesKey) { if (!this.plugin.settings.MobyGamesKey) {
throw Error(`MDB | API key for ${this.apiName} missing.`); console.log(Error(`MDB | API key for ${this.apiName} missing.`));
} }
const searchUrl = `${this.apiUrl}/games?id=${encodeURIComponent(id)}&api_key=${this.plugin.settings.MobyGamesKey}`; const searchUrl = `${this.apiUrl}/games?id=${encodeURIComponent(id)}&api_key=${this.plugin.settings.MobyGamesKey}`;

View file

@ -29,7 +29,8 @@ export class OMDbAPI extends APIModel {
console.log(`MDB | api "${this.apiName}" queried by Title`); console.log(`MDB | api "${this.apiName}" queried by Title`);
if (!this.plugin.settings.OMDbKey) { if (!this.plugin.settings.OMDbKey) {
throw Error(`MDB | API key for ${this.apiName} missing.`); console.error(Error(`MDB | API key for ${this.apiName} missing.`));
return [];
} }
const searchUrl = `https://www.omdbapi.com/?s=${encodeURIComponent(title)}&apikey=${this.plugin.settings.OMDbKey}`; const searchUrl = `https://www.omdbapi.com/?s=${encodeURIComponent(title)}&apikey=${this.plugin.settings.OMDbKey}`;
@ -222,4 +223,4 @@ export class OMDbAPI extends APIModel {
return; return;
} }
} }