-
-
Save Ivshti/4632556a6d7619de05393440e2789d20 to your computer and use it in GitHub Desktop.
cf worker for last-videos catalog (metasDetailed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event.request)) | |
}) | |
async function handleRequest(request) { | |
const urls = [ | |
"https://v3-channels.strem.io/meta/channel/yt_id%3AUCa90xqK2odw1KV5wHU9WRhg/lastVideos=1.json", | |
"https://v3-channels.strem.io/meta/channel/yt_id%3AUCa90xqK2odw1KV5wHU9WRhg/lastVideos=1.json" | |
] | |
const allRequests = urls.map(async u => { | |
const response = await fetch(u) | |
const { meta } = await response.json() | |
return meta | |
}) | |
const resp = { metasDetailed: await Promise.all(allRequests) } | |
// @TODO consider headers from the first response | |
const headers = { 'content-type': 'application/json; charset=utf-8' } | |
return new Response(JSON.stringify(resp), { headers }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment