more stuff

This commit is contained in:
mProjectsCode 2022-05-06 23:45:22 +02:00
parent 42610459d5
commit c7a75ff93c
5 changed files with 55 additions and 9 deletions

View file

@ -22,6 +22,10 @@ export class OMDbAPI extends APIModel {
const searchUrl = `http://www.omdbapi.com/?s=${title}&apikey=${this.plugin.settings.OMDbKey}`;
const fetchData = await fetch(searchUrl);
if (fetchData.status === 401) {
throw Error(`Authentication for ${this.apiName} failed. Check the API key.`);
}
if (fetchData.status !== 200) {
throw Error(`Received status code ${fetchData.status} from an API.`);
}
@ -55,6 +59,9 @@ export class OMDbAPI extends APIModel {
const searchUrl = `http://www.omdbapi.com/?i=${item.id}&apikey=${this.plugin.settings.OMDbKey}`;
const fetchData = await fetch(searchUrl);
if (fetchData.status === 401) {
throw Error(`Authentication for ${this.apiName} failed. Check the API key.`);
}
if (fetchData.status !== 200) {
throw Error(`Received status code ${fetchData.status} from an API.`);
}