Question

I am using nodejs. I am trying to called the vimeo api using a module called vimeo (https://www.npmjs.org/package/vimeo)

Below is my code.

var key = 'my key'; // vimeo api key
var secret = 'my secret'; // vimeo api secret
var vimeo = require('vimeo')(key, secret);
var params = { query: 'funny video', sort:'most_played',per_page:1 };
var vtitle;
vimeo.videos('search', params, function(err, resq) {
    vtitle= resq.videos.video.title;
    console.log("Get title "+vtitle);
});

This is what the vimeo api returns when i called via their playground. (https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.search/playground)

enter image description here

I can console.log resq.videos.video. It is viewed as an [object] in my console. However, when i tried to get the title, it returns undefined. e.g resq.videos.video.title

Appreciate any advice!

Was it helpful?

Solution

The field resq.videos.video is an array, so if you make it resq.videos.video[0].title you should see the first title.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top