Search code examples
node.jsvimeovimeo-api

Video upload using the vimeo api in node js is not working?


I have referred this link for the video upload and node module https://github.com/vimeo/vimeo.js

This is my code snippet to upload video

var Vimeo = require('vimeo-api').Vimeo;

    CLIENT_ID = CLIENT_ID;
    CLIENT_SECRET = CLIENT_SECRET;
    console.log('1');
    var lib = new Vimeo(CLIENT_ID, CLIENT_SECRET);
    console.log('2');

    lib.generateClientCredentials(scope, function (err, access_token) {
        if (err) {
                throw err;
        }
        console.log('3');
        var token = access_token.access_token;
        var scopes = access_token.scope;
    });

    lib.upload('youtube/test4.mp4',  function (error, body, status_code, headers) {
        if (err) {
            throw err;
        }
        console.log('4');
        lib.request(headers.location, function (error, body, status_code, headers) {
            console.log(body);
        });
    });

}

It show a error such as object is not a function . I have found this error is been in this line by using the console.log

var lib = new Vimeo(CLIENT_ID, CLIENT_SECRET);

Solution

  • This issue is because of a object has been declared in the same name in the lib file, so I have changed the name of the object. It works fine now.