0

Inside a SPFx web part, I have been trying really hard to list out the labels (red, blue, green) within the Favourite term set. I have not yet been able to achieve this.

Does anybody know how to do this? My brain is melting :(

code:

  public async componentDidMount() {

    const store: ITermStore = taxonomy.termStores.getByName("Taxonomy_O1cHqzMmDZNz4UeaKJLVpA==");

    // get a single term by id
    const term: ITerm = store.getTermById("6a488843-cebc-47b7-8606-e4e165e6fceb");

    const labels: ILabels = term.labels;

    const labelsWithData = term.labels.get();

    { setTimeout(() => {
      console.log('1', store);
      console.log('2',labels);
      console.log('3',labelsWithData);
    }, 2000); }

  }

enter image description here

1 Answer 1

1

Sample test code for your reference.

public componentDidMount() {

    var store: ITermStore = taxonomy.termStores.getByName("Taxonomy_hAIlyuIrZSNizRU+uUbanA==");
    var set: ITermSet = store.getTermSetById("70719569-ae34-4f24-81b9-0629d68c05aa");    
    // load the data into the terms instances
    set.terms.get().then((terms:ITerm[])=>{
      terms.forEach((term: ITerm) => {
        console.log(term['Name']);
      })
    });
}

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.