So I'm trying to get value from my result sources by using a GET request but I'm having trouble iterating to the items as they are under: "PrimaryQueryResult.RelevantResults.Table.Rows"

And I don't know how to retrieve from there so that I can display them

Get request :

export interface ProjectInformations {
PrimaryQueryResult: ProjectInformation[];

public render(): void {

private _renderPersonAsync(): void {
  .then((response) => {

private _getData(): Promise<ProjectInformations> {
this.context.spHttpClient.get(this.context.pageContext.site.absoluteUrl +
  SPHttpClient.configurations.v1, {
    .then((response: SPHttpClientResponse): 
    Promise<ProjectInformations> => {
    return response.json();

Solved it by using alot of Export interfaces:

export interface ISearchResults {
PrimaryQueryResult: IPrimaryQueryResult;

 export interface IPrimaryQueryResult {
 RelevantResults: IRelevantResults;

 export interface IRelevantResults {
 Table: ITable;

 export interface ITable {
  Rows: Array<ICells>;

 export interface ICells {
 Cells: Array<ICellsValue>;

 export interface ICellsValue {
 Key: string;
 Value: string;
 ValueType: string;

chain one more promise ie .then(()=>{}) and form an result array and return the result array

 if (data.PrimaryQueryResult.RelevantResults.Table.Rows) {
        var restResults = 
        var popularRestResults = new Array();

        for (var i = 0; i < restResults.length; i++) {
            var propertyResults: any = {};
            for (var j = 0; j < restResults[i].Cells.length; j++) {
                propertyResults[restResults[i].Cells[j]["Key"]] = restResults[i].Cells[j]["Value"];
            popularRestResults[i] = propertyResults;

        //create the ProjectInformations array by looping over popularRestResults and return the array
        return popularRestResults;

hope this helps!


You can use this example: Link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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