javascript - Node JS - Youtube API 为空白

标签 javascript node.js youtube youtube-data-api google-api-nodejs-client

我使用 npm install googleapis 下载并安装了 google api,现在我尝试使用以下代码访问我的 Node js 文件中的 api:

var google = require('googleapis')
var youtube = google.youtube({version: 'v3', auth: API_KEY})

但是,当我尝试访问视频对象时,我总是返回 null。显然,youtube 对象已损坏,因为当我对其进行字符串化时,我得到了它:

{"_options":{"auth":"*********"},"activities":{},"captions":{},"channelBanners":{},"channelSections":{},"channels":{},"commentThreads":{},"comments":{},"guideCategories":{},"i18nLanguages":{},"i18nRegions":{},"liveBroadcasts":{},"liveStreams":{},"playlistItems":{},"playlists":{},"search":{},"subscriptions":{},"thumbnails":{},"videoAbuseReportReasons":{},"videoCategories":{},"videos":{},"watermarks":{},"google":{"_options":{},"auth":{"_cachedCredential":null}}}

所以所有的小“子对象”都是空的。我该如何解决这个问题?

最佳答案

您是否检查过依赖项是否列在您的 package.json 文件中?如果不尝试 npm install --save googleapis 直接将其添加到您的依赖列表

关于javascript - Node JS - Youtube API 为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35531047/

相关文章:

Javascript 正则表达式返回 null,node.js

node.js - 在 wsl 2 中安装不同的 Node 版本

node.js - 如何识别哪些 npm 包只是对等依赖项?

javascript - 是否可以在youtube.com中控制嵌入式视频播放器?

android - 为什么 YouTube API 在 5.0 及更高版本中不起作用?

css - 在同一行上插入两个自适应YouTube视频

javascript - 将单行展开为多行

javascript空字段表单验证不起作用

javascript - Node.js 如何执行多任务功能

javascript - firebase 回调中无法识别异步函数