tonickkozlov / vue-tweet-embed

Embed tweets in your vue.js app
111 stars 27 forks source link

Pre existing window.twttr object causes uncaught errors #51

Open matt-sanders opened 4 years ago

matt-sanders commented 4 years ago

Sometimes window.twttr will exist without the widgets property. This could be due to twitter analytics or ads. I came across this when twitter scripts were being embedded on a site via GTM. This results in a bunch of errors, specifically:

Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating '(t=e.widgets).createTweetEmbed')

The current implementation checks to see if window.twttr is defined before trying to load the twitter platform scripts. The solution here is to also check that window.twttr.widgets is available.