adjusting check for null feed
This commit is contained in:
57
libFlayer.js
57
libFlayer.js
@@ -123,7 +123,7 @@ exports.loadFeeds = function () {
|
||||
linkFlayerCats = [];
|
||||
|
||||
base(userTable)
|
||||
.select().firstPage(function(err, records) {
|
||||
.select().firstPage(function (err, records) {
|
||||
try {
|
||||
records.forEach(function (record) {
|
||||
console.log('Retrieved title: ', record.get('title'));
|
||||
@@ -169,12 +169,13 @@ exports.loadFeeds = function () {
|
||||
feeds.forEach(feedBlock => {
|
||||
(async () => {
|
||||
|
||||
const feed = parser.parseURL(feedBlock.link, function (err, feed) {
|
||||
if (err) {
|
||||
console.log(err + " " + feedBlock.link);
|
||||
//return;
|
||||
}
|
||||
if (feed.items !== null) {
|
||||
const feed = parser.parseURL(feedBlock.link, function (err, feed) {
|
||||
if (err) {
|
||||
console.log(err + " " + feedBlock.link);
|
||||
//return;
|
||||
}
|
||||
|
||||
if (feed !== null) {
|
||||
feed.items.forEach(item => {
|
||||
var foundFeed = false;
|
||||
linkFlayerMap.forEach(linkFlay => {
|
||||
@@ -195,7 +196,7 @@ exports.loadFeeds = function () {
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
})().then();
|
||||
});
|
||||
@@ -250,12 +251,12 @@ exports.getSlang = async function (question) {
|
||||
.then(response => {
|
||||
console.log(response.data.list[0]);
|
||||
|
||||
slangData = {
|
||||
definition: `${unescape(response.data.list[0].definition)}`,
|
||||
example: `${unescape(response.data.list[0].example)}`,
|
||||
thumbs_down: `${unescape(response.data.list[0].thumbs_down)}`,
|
||||
thumbs_up: `${unescape(response.data.list[0].thumbs_up)}`
|
||||
}
|
||||
slangData = {
|
||||
definition: `${unescape(response.data.list[0].definition)}`,
|
||||
example: `${unescape(response.data.list[0].example)}`,
|
||||
thumbs_down: `${unescape(response.data.list[0].thumbs_down)}`,
|
||||
thumbs_up: `${unescape(response.data.list[0].thumbs_up)}`
|
||||
}
|
||||
|
||||
return slangData;
|
||||
})
|
||||
@@ -286,17 +287,17 @@ exports.getStock = async function (stock) {
|
||||
//console.log(response.data.list[0]);
|
||||
|
||||
stockData = {
|
||||
symbol: `${unescape(response.data["Global Quote"]['01. symbol'])}`,
|
||||
open: `${unescape(response.data["Global Quote"]['02. open'])}`,
|
||||
high: `${unescape(response.data["Global Quote"]['03. high'])}`,
|
||||
low: `${unescape(response.data["Global Quote"]['04. low'])}`,
|
||||
price: `${unescape(response.data["Global Quote"]['05. price'])}`,
|
||||
volume: `${unescape(response.data["Global Quote"]['06. volume'])}`,
|
||||
latest: `${unescape(response.data["Global Quote"]['07. latest trading day'])}`,
|
||||
previous: `${unescape(response.data["Global Quote"]['08. previous close'])}`,
|
||||
change: `${unescape(response.data["Global Quote"]['09. change'])}`,
|
||||
percent: `${unescape(response.data["Global Quote"]['10. change percent'])}`
|
||||
}
|
||||
symbol: `${unescape(response.data["Global Quote"]['01. symbol'])}`,
|
||||
open: `${unescape(response.data["Global Quote"]['02. open'])}`,
|
||||
high: `${unescape(response.data["Global Quote"]['03. high'])}`,
|
||||
low: `${unescape(response.data["Global Quote"]['04. low'])}`,
|
||||
price: `${unescape(response.data["Global Quote"]['05. price'])}`,
|
||||
volume: `${unescape(response.data["Global Quote"]['06. volume'])}`,
|
||||
latest: `${unescape(response.data["Global Quote"]['07. latest trading day'])}`,
|
||||
previous: `${unescape(response.data["Global Quote"]['08. previous close'])}`,
|
||||
change: `${unescape(response.data["Global Quote"]['09. change'])}`,
|
||||
percent: `${unescape(response.data["Global Quote"]['10. change percent'])}`
|
||||
}
|
||||
|
||||
return stockData;
|
||||
})
|
||||
@@ -320,9 +321,9 @@ exports.getSources = function () {
|
||||
* getQuotes - Returns libFlayer feed quotes
|
||||
* @constructor
|
||||
*/
|
||||
exports.getQuotes = async function (quote_url) {
|
||||
exports.getQuotes = async function (quote_url) {
|
||||
|
||||
var data = [];
|
||||
var data = [];
|
||||
await axios.get(quote_url)
|
||||
.then(response => {
|
||||
console.log(response.data[0].q);
|
||||
@@ -334,7 +335,7 @@ var data = [];
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user