wait until unswer is ready
This commit is contained in:
@@ -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=>{
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
Reference in New Issue
Block a user