VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.89k forks source link

The getEmbedData({url}) Not Giving The Proper Data #1727

Closed ghost closed 7 years ago

ghost commented 7 years ago

The result of the following code not giving the proper data

const result = await this.props.getEmbedData({url});

Some times it is not getting the title, body and most of the time it is not getting the thumbnail

Hoe to fix this problem?

SachaG commented 7 years ago

Which embed provider are you using?

ghost commented 7 years ago

I am using the code from the following link

https://github.com/VulcanJS/Vulcan/blob/master/packages/vulcan-embedly/lib/components/EmbedlyURL.jsx

SachaG commented 7 years ago

I know but which service are you using for providing the embed metadata? If it's just the built-in plugin, I haven't really tested it much so it's possible that it doesn't work perfectly.

ghost commented 7 years ago

I am using builtin embed provider see the following code:

const embedProvider = getSetting('embedProvider', 'builtin');

SachaG commented 7 years ago

I want to change it anyway. For now I would suggest using Embedly or EmbedAPI, or else if you want to submit a PR you could try implementing https://github.com/ianstormtaylor/metascraper ?

ghost commented 7 years ago

I am using the following code

import Embed from '../../modules/embed.js';
import Metascraper from 'metascraper';

Embed.builtin = {

  getData(url) {

        let metadata = Metascraper.scrapeUrl(url);
   // console.log(metadata,'::: metadata')
    // const metadata = extractMeta(url);

    return {
      title: metadata.title,
      description: metadata.description,
      thumbnailUrl: metadata.image,
    }
  }
}

But it is getting undefined


{ title: undefined,
   description: undefined,
   thumbnailUrl: undefined 
}
SachaG commented 7 years ago

I think you need to use async/await?

ghost commented 7 years ago

How to do this?

SachaG commented 7 years ago

See the examples in Metascraper readme

ghost commented 7 years ago

Ok Thanks