promisify answer on user defined question

This commit is contained in:
GotPPay
2018-03-30 12:08:38 +02:00
parent f163dde5b2
commit 0ebadcd3f7
2 changed files with 25 additions and 9 deletions

View File

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