【问题标题】:Getting search results for a category from the YouTube API从 YouTube API 获取类别的搜索结果
【发布时间】:2020-10-01 23:35:33
【问题描述】:

由于文档非常大,我无法为我的问题找到正确的 Youtube API Docs 查询。

如何显示某些特定类别的 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);
    });
});



【问题讨论】:

标签: javascript node.js express youtube youtube-api


【解决方案1】:

使用

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;
    }
  }

【讨论】:

    猜你喜欢
    • 2018-02-13
    • 1970-01-01
    • 2019-06-14
    • 2015-02-14
    • 2018-11-15
    • 1970-01-01
    • 2017-08-27
    • 2018-06-16
    • 2019-09-10
    相关资源
    最近更新 更多