Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"node": ">=18.0.0"
},
"dependencies": {
"axios": "^1.11.0",
"body-parser": "^1.20.3",
"express": "^4.21.2",
"open": "^10.2.0",
Expand Down
11 changes: 7 additions & 4 deletions src/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import axios from 'axios'

const YOUTUBE_API_URL = 'https://www.googleapis.com/youtube/v3/search'

const youtubeAPI = async (query, options) => {
Expand All @@ -14,9 +12,14 @@ const youtubeAPI = async (query, options) => {
console.error('Whoops! You should setup your YouTube Data API key')
}

const response = await axios.get(YOUTUBE_API_URL, { params })
// Build URL with query parameters
const url = new URL(YOUTUBE_API_URL)
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))

const response = await fetch(url)
const data = await response.json()

return response.data.items.map(item => {
return data.items.map(item => {
let id, link, linkEmbed, kind

switch (item.id.kind) {
Expand Down