@KioMio wrote:
I need to return the boolean result of a file readAsText promise to an array filter method. The promise returns the correct value, based on the inputs. But I do not know how to get a value for the “return” function. First is the called function, followed by the array filter code segment.
phraseFound(path: string, phrase: string) {
let panelMediaFile = ‘panelMedia_’ + this.global.langAbbv + ‘.json’;return this.file.readAsText(this.global.fileSystem.int + path, panelMediaFile).then((jsonStr) => { let found = (jsonStr.toLowerCase().indexOf(phrase) == -1) ? false : true; return found; //found = TRUE }).catch((err) => { this.global.showError('t10', err); });
}
filteredItems = filteredItems.filter( item => { let tapaSrcPath = this.global.path.titles + item.titleURI + '/tapaSrc/'; let found = this.phraseFound(tapaSrcPath, searchTermsPhrase) .then(found => { return found; //found = TRUE }); return found; //found = promise object });
Thank you in advance!
Posts: 1
Participants: 1