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 {
this._renderPersonAsync();
}
private _renderPersonAsync(): void {
this._getData()
.then((response) => {
this._getSearchData(response.PrimaryQueryResult);
});
}
private _getData(): Promise<ProjectInformations> {
return
this.context.spHttpClient.get(this.context.pageContext.site.absoluteUrl +
`/_api/search/query?querytext='(GetDocument:"docx")'
&selectproperties='Title%2cPath%2cProjectStatus%2cUrl'
&sortlist='refinablestring08:ascending'
&properties='SourceLevel:SPSiteSubscription,SourceName:Project'`,
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;
}