从 YouTube 获取某个类别的搜索结果 API
Getting search results for a category from the YouTube API
我无法找到 Youtube 的正确查询 API 我的问题的文档,因为文档非常大。
如何显示某些特定类别的 YouTube 视频,例如 旅行 或 技术 最多 30 个结果 我怎样才能得到搜索特定关键字的结果
我在 Express.js 上的初始代码:
app.get("/videos2", (req, res) => {
const url2 = "https://www.googleapis.com/youtube/v3/videos";
fetch(`${url2}&key=${process.env.GOOGLE_API_KEY}`)
.then((response) => {
return response.json();
})
.then((json) => {
res.json(json);
});
});
使用
sync function getAllUrls(urls) {
try {
var data = await Promise.all(
urls.map((url) =>
fetch(url)
.then((response) => {
return response.json();
})
.then((json) => {
return json.items;
})
)
);
return data;
} catch (error) {
console.log(error);
throw error;
}
}
我无法找到 Youtube 的正确查询 API 我的问题的文档,因为文档非常大。
如何显示某些特定类别的 YouTube 视频,例如 旅行 或 技术 最多 30 个结果 我怎样才能得到搜索特定关键字的结果
我在 Express.js 上的初始代码:
app.get("/videos2", (req, res) => {
const url2 = "https://www.googleapis.com/youtube/v3/videos";
fetch(`${url2}&key=${process.env.GOOGLE_API_KEY}`)
.then((response) => {
return response.json();
})
.then((json) => {
res.json(json);
});
});
使用
sync function getAllUrls(urls) {
try {
var data = await Promise.all(
urls.map((url) =>
fetch(url)
.then((response) => {
return response.json();
})
.then((json) => {
return json.items;
})
)
);
return data;
} catch (error) {
console.log(error);
throw error;
}
}