我使用 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/