Skip to content

Commit

Permalink
Catch error when IMDB search returns no results
Browse files Browse the repository at this point in the history
  • Loading branch information
SegiH committed Dec 17, 2021
1 parent d485014 commit d51eb15
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 217 deletions.
216 changes: 1 addition & 215 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@angular-eslint/eslint-plugin": "~12.0.0",
"@angular-eslint/eslint-plugin-template": "~12.0.0",
"@angular-eslint/template-parser": "~12.0.0",
"@angular/cli": "~12.1.1",
"@angular/cli": "12.1.4",
"@angular/compiler": "~12.1.1",
"@angular/compiler-cli": "~12.1.1",
"@angular/language-service": "~12.0.1",
Expand Down
6 changes: 5 additions & 1 deletion src/app/imdb-search/imdb-search.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export class IMDBSearchPage {
searchIMDB() {
if (this.searchTerm != '' && this.searchTerm != null) {
this.dataService.searchIMDB(this.searchTerm).subscribe((response) => {
this.searchResults=Object.entries(response)[0][1]; // This contains the actual search results
if (response.Response == "False") {
alert(`${response.Error}`)
} else {
this.searchResults=Object.entries(response)[0][1]; // This contains the actual search results
}
},
error => {
console.log(`An error occurred searching IMDB`)
Expand Down

0 comments on commit d51eb15

Please sign in to comment.