Skip to content

Commit

Permalink
Do not throw when youtube search fails
Browse files Browse the repository at this point in the history
  • Loading branch information
danguilherme committed Mar 12, 2022
1 parent 68128a2 commit ac3c8d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion youtube_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function searchVideo(term, { logger } = {}) {
q: term,
type: 'video',
},
(error, { data }) => {
(error, response) => {
if (error) {
const quotaExceededError = error.errors.find(
e => e.domain === 'youtube.quota' && e.reason === 'quotaExceeded'
Expand All @@ -48,6 +48,8 @@ function searchVideo(term, { logger } = {}) {
return reject(error);
}

const { data } = response;

debug(logger, `Search video: ${data.items.length} item(s) returned`);
resolve(data.items);
}
Expand Down

0 comments on commit ac3c8d2

Please sign in to comment.