0

I'm trying to use Facebook SDK with nuxt.js referring this post post link. But It's says window.FB is undefined.

How can I solve this issue or is any other way to use Facebook SDK in nuxt.js?

fb-sdk.js

window.fbAsyncInit = function() {
    FB.init({
      appId      : '############',
      cookie     : true,
      xfbml      : true,
      version    : 'v9.0'
    });
      
    FB.AppEvents.logPageView();       
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "https://connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));


method

fbLog() 
{
      window.FB.getLoginStatus(function (response) {
        this.statusChangeCallback(response)
      })
    },
    statusChangeCallback(response) {
      console.log(response)
 },

nuxt.config.js

head: {
    titleTemplate: '%s - test',
    title: 'test',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
    script: [
      { src: 'js/fb-sdk.js' }
     ],
  },
Tharindu Prabodhana
  • 181
  • 1
  • 4
  • 16

1 Answers1

0

Solve the problem, Problem is I'm trying it on Firefox and the Firefox tracking option disable that script after turn off it works as expected.

Tharindu Prabodhana
  • 181
  • 1
  • 4
  • 16