search by id
This commit is contained in:
parent
62a4f2ec56
commit
92f3e6bab8
13 changed files with 183 additions and 29 deletions
|
|
@ -32,6 +32,10 @@ export class OMDbAPI extends APIModel {
|
|||
}
|
||||
const data = await fetchData.json();
|
||||
|
||||
if (data.Response === 'False') {
|
||||
throw Error(`Received error from ${this.apiName}: ${data.Error}`);
|
||||
}
|
||||
|
||||
if (!data.Search) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -76,14 +80,20 @@ export class OMDbAPI extends APIModel {
|
|||
}
|
||||
|
||||
const result = await fetchData.json();
|
||||
|
||||
console.log(result);
|
||||
|
||||
if (result.Response === 'False') {
|
||||
throw Error(`Received error from ${this.apiName}: ${result.Error}`);
|
||||
}
|
||||
|
||||
if (result.Type === 'movie') {
|
||||
const model = new MovieModel({
|
||||
type: 'movie',
|
||||
title: result.Title,
|
||||
year: result.Year,
|
||||
dataSource: this.apiName,
|
||||
url: `https://www.imdb.com/title/${result.imdbID}/`,
|
||||
id: result.imdbID,
|
||||
|
||||
genres: result.Genre?.split(', ') ?? [],
|
||||
|
|
@ -107,6 +117,7 @@ export class OMDbAPI extends APIModel {
|
|||
title: result.Title,
|
||||
year: result.Year,
|
||||
dataSource: this.apiName,
|
||||
url: `https://www.imdb.com/title/${result.imdbID}/`,
|
||||
id: result.imdbID,
|
||||
|
||||
genres: result.Genre?.split(', ') ?? [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue