Skip to content

Commit

Permalink
add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Doarakko committed Aug 21, 2024
1 parent 147f472 commit 85444b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ async function run() {

fetch("https://db.ygoprodeck.com/api/v7/randomcard.php")
.then((response) => {
if(!response.ok){
console.error('response.ok:', response.ok);
console.error('esponse.status:', response.status);
console.error('esponse.statusText:', response.statusText);
throw new Error("Failed to fetch random card");
}
return response.json();
})
.then((data) => {
Expand Down

0 comments on commit 85444b0

Please sign in to comment.