{"size": 686, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "abhiram308/GoogleAssistantInshortsApp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "abhiram308/GoogleAssistantInshortsApp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "abhiram308/GoogleAssistantInshortsApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.4074074074, "max_line_length": 62, "alphanum_fraction": 0.6064139942}
const request = require('request');
const cheerio = require('cheerio');
const _ = require('lodash');

const initFeedUrl = 'https://www.inshorts.com/en/read/';

exports.getNewsFromInshorts = function callapi() {
	return new Promise((resolve, reject) => {
		request(initFeedUrl, { json: true }, (err, res, body) => {
			if(err) {
				reject();
			}
			if(res.statusCode == 200) {
				const $ = cheerio.load(body);
				var news = new Array();
				_.forEach($("[itemprop='articleBody']"), function(_news) {
					news.push(_news.children[0].data);
				});
				resolve(news.join(' Next Item, '))
			}
			else {
				err = "Error getting response from inshorts";
				reject();
			}
		});
	});
}