Skip to content

Commit

Permalink
refactor: log parse errors from moviedb to console
Browse files Browse the repository at this point in the history
  • Loading branch information
treipatru committed Aug 13, 2024
1 parent 443c7d1 commit 3044c4e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/api/moviedb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ export async function getDiscoverMovie(
});

const resJSON = await response.json();
const data = paginatedMoviesSchema.parse(resJSON);
const { data, error } = paginatedMoviesSchema.safeParse(resJSON);

if (error) {
console.log(error.flatten());
throw new Error('Failed to parse response from MovieDB API');
}

return data;
}

0 comments on commit 3044c4e

Please sign in to comment.