In my attempt to create a comprehensive keyword list from the existing keywords, I successfully retrieved them all and displayed them in the debug console.
However, I am facing confusion regarding the appropriate time and method to call resolve(taxonomyKeywords)
. I have tried using a foreach
loop, but encountered the same issue. Is my approach completely off track, or is there a simpler solution that I am missing?
private searchKeyword(searchTerm: string, results: ITag[]) : ITag[] | Promise<ITag[]>
{
return new Promise<IPersonaProps[]>( (resolve, reject) => {
let taxonomyKeywords : ITag[] = [];
this.props.taxonomyProvider.getTermStores().then( (stores: ITermStore[]) => {
for(var store of stores )
{
this.props.taxonomyProvider.getTermGroups( store.id ).then( (groups: ITermGroup[]) => {
for(var group of groups)
{
this.props.taxonomyProvider.getTermSets(group).then( (sets: ITermSet[]) => {
for(var termSet of sets)
{
this.props.taxonomyProvider.getTerms(termSet).then( (terms: ITerm[]) => {
for(var term of terms)
{
if( term.name.indexOf(searchTerm) >= 0 )
{
taxonomyKeywords.push( { key: term.name, name: term.name} );
}}});}});}});}});});}