wait until unswer is ready

This commit is contained in:
GotPPay
2018-03-30 11:52:04 +02:00
parent 431daa3182
commit f163dde5b2
2 changed files with 3 additions and 7 deletions

View File

@@ -33,10 +33,10 @@ getDataFromWPJSON = function (sourceUrl, page = 1, maxPosts = 10) {
} }
module.exports = { module.exports = {
getAnswerFromWP : function (sourceUrl){ getAnswerFromWP : async function (sourceUrl){
//This function will extract needed data from JSON, which we got from getDataFromWPJSON //This function will extract needed data from JSON, which we got from getDataFromWPJSON
//At the moment, it's taking titles and creates answer //At the moment, it's taking titles and creates answer
return new Promise((resolve,reject)=>{ return await new Promise((resolve,reject)=>{
getDataFromWPJSON(sourceUrl).then(rawData=>{ getDataFromWPJSON(sourceUrl).then(rawData=>{
let result=''; let result='';
rawData.forEach(post=>{ rawData.forEach(post=>{

View File

@@ -77,11 +77,7 @@ module.exports = {
answer = intent.answer; answer = intent.answer;
break; break;
case constants.answerType.EXTERNAL_SOURCE_WP_JSON: case constants.answerType.EXTERNAL_SOURCE_WP_JSON:
predefinedSourceHelper.getAnswerFromWP(intent.externalAnswerSource).then(result=>{ answer = predefinedSourceHelper.getAnswerFromWP(intent.externalAnswerSource);
answer=result;
}).catch(err=>{
answer=err;
});
break; break;
case constants.answerType.EXTERNAL_SOURCE_RSS: case constants.answerType.EXTERNAL_SOURCE_RSS:
answer = 'Not implemented yet' answer = 'Not implemented yet'