Youtube api Youtube数据API V3-使用google.Youtube.videos.list()获取视频时出错
我在尝试通过Id获取youtube视频时遇到一个神秘错误:Youtube api Youtube数据API V3-使用google.Youtube.videos.list()获取视频时出错,youtube-api,youtube-data-api,Youtube Api,Youtube Data Api,我在尝试通过Id获取youtube视频时遇到一个神秘错误: TypeError:无法读取未定义的属性“0” 我以前使用googleapi nodejs-client的(16.1.0)实现了这一点,但在更新包之后,它似乎不再工作了 以下是我正在使用的代码: const { google } = require('googleapis'); const youtube = google.youtube({ version: 'v3', auth: process.env.YOUTUBE_KEY })
TypeError:无法读取未定义的属性“0”
我以前使用googleapi nodejs-client
的(16.1.0)实现了这一点,但在更新包之后,它似乎不再工作了
以下是我正在使用的代码:
const { google } = require('googleapis');
const youtube = google.youtube({ version: 'v3', auth: process.env.YOUTUBE_KEY });
youtube.videos.list({
id: 'Txlk7PiHaGk',
part: 'snippet, contentDetails'
}, (err, video) => {
if (err) {
console.error(`Error fetching Youtube Video: ${err}`);
}
// success..
});
由于某种原因,我的请求每次都会出错
如果您能提供任何帮助,我们将不胜感激。最近,据报道,最近发布的node.js的googleapis有一些错误。我已经确认了他们的Gmail API,驱动API和表单API。同样在Youtube API上,我也发现了同样的情况。我确认,对于Youtube API,您的脚本在v27.0.0、v26.0.0和v25.0.0中不起作用 当我使用v24.0.0时,它工作得很好 那么,您可以降级到v24.0.0并重试吗?此时,请修改from
const{google}=require('googleapis')
toconst google=require('googleapis')代码>我相信这些错误将在将来的更新中删除
参考资料:
如果这些信息对您没有用处,我很抱歉。真棒的人,谢谢。我意识到我落后了很多。很高兴能更及时地更新。Cheers@Celestriel谢谢你的回复。从你的问题中,我可以知道Youtube API的这个版本错误。我想把你的问题补充到以后的答案中。我认为这将帮助其他用户解决相同的错误。