How to implement or install the vimeo.js on the NuxtJs/VueJs?

Viewed 190

Im try to use vimeo upload api using vimeo nodejs sdk https://github.com/vimeo/vimeo.js i have successfully install it using plugin in nuxt config.The problem how to apply the vimeo to my vue files. this is my code:

plugins/vimeo.js

var Vimeo = require('vimeo').Vimeo;
console.log(Vimeo);
var client = new Vimeo(process.env.CLIENT_ID, process.env.CLIENT_SECRET, process.env.ACCESS_TOKEN);
console.log(client);

nuxt.config.js

  plugins: [
    '~/plugins/vform.js',
    '~/plugins/VuePlugins.js',
    {src:'~/plugins/vimeo.js', mode:'server'}
  ],

pages/sample.vue

    methods: {
      upload(){
            this.$client.upload(
            '/home/aaron/Downloads/ada.mp4',
            function (uri) {
              console.log('File upload completed. Your Vimeo URI is:', uri)
            },
            function (bytesUploaded, bytesTotal) {
              var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
              console.log(bytesUploaded, bytesTotal, percentage + '%')
            },
            function (error) {
              console.log('Failed because: ' + error)
            }
          )
      }
        },
0 Answers
Related