From ccce3dc172ee252378db73c8409f7204301f70c7 Mon Sep 17 00:00:00 2001 From: Hippo Date: Fri, 11 Oct 2019 16:25:52 +0530 Subject: [PATCH] Implement basic fetchFromMedium command --- functions.js | 6 ++++-- index.js | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/functions.js b/functions.js index b245493..669ed26 100644 --- a/functions.js +++ b/functions.js @@ -1,11 +1,13 @@ const r2 = require('r2') +const getPost = require('mediumexporter').getPost /** * function [fetchFromMedium] * @returns [string] status */ -const fetchFromMedium = (mediumUrl) => { - console.info('Fetching: ' + mediumUrl); +const fetchFromMedium = async (mediumUrl) => { + console.debug('Fetching: ' + mediumUrl); + return await getPost(mediumUrl, { returnObject: true }) }; /** diff --git a/index.js b/index.js index 096bc29..8d449a2 100755 --- a/index.js +++ b/index.js @@ -17,7 +17,11 @@ program.command('fetch-medium ') .alias('fetch') .description('fetch a Medium post') .action((post_url) => { - fetchFromMedium(post_url); + fetchFromMedium(post_url) + .then((post) => { + console.info(`"${post.title}" fetched successfully`) + console.debug(post) + }) }); program.command('push-ghost ')