ms-seo
ms-seo copied to clipboard
Scoping Issue?
I'm seeing a weird issue in Meteor 1.0.3 where SEO.set({ ... }); isn't able to see my local post variable. Code below:
onAfterAction: function() {
if (!Meteor.isClient) {
return;
}
var post = this.data();
SEO.set({
'title': post.title,
'meta': {
'description': post.short
},
'og': {
'title': post.title,
'description': post.short,
'image': post.image_url
}
});
}
Exception in callback of async function: TypeError: Cannot read property 'title' of undefined (this is throwing at the first call of post.title)
The data exists, if I do console.log(post) I can see everything I'm looking for. Any suggestions?
This is what i do
(function(title, description) {
SEO.set({
title: title,
meta: {
'description': description
},
og: {
'title': title,
'description': description
}
});
})(data.title, description);
@struCoder Thanks for that, turns out the "onAfterAction" function was running twice so I just throw a if this.data() == undefined check above SEO.set
Follow-up question. Am I supposed to call this in onAfterAction...? Looking up my pages in Facebook's Open Graph debugger I can't see any of the info I need:
https://developers.facebook.com/tools/debug/og/object/
Try entering http://beta.untuckedstyle.com/drinks/tequila%20and%20weight%20loss
@NewETown Would you mind sharing the code you used to avoid the SEO.set triggering the onAfterAction twice? Thank you!