twitter.js 346 B

12345678910111213141516
  1. let axios = require('axios');
  2. module.exports = {
  3. matches (url) {
  4. return url.match(/^https?:\/\/(www\.)?twitter\.com\/.+\/status\/\d+/i);
  5. },
  6. async getPreviewData (url) {
  7. try {
  8. let res = await axios.get('https://publish.twitter.com/oembed?url=' + url);
  9. return res.data.html;
  10. } catch (e) {
  11. console.log(e)
  12. return null;
  13. }
  14. }
  15. };