I am trying to get all the users from the local people directory and display it. If I type this in the browser, I see all the data I need. If I use this in my code and compile it in spfx it does not work. may I know what is the fix ?
My search query
qurl="/_api/search/query?querytext=''&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&rowlimit=60";
- The code
private getUser(){
var qurl;
qurl="/_api/search/query?querytext=''&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&rowlimit=60";
const opt: ISPHttpClientOptions = { headers: {
'Content-Type': 'application/json;odata=verbose'
}};
this.props.SPHttpClient.get(this.props.pagecontext.web.absoluteUrl + qurl, SPHttpClient.configurations.v1,opt)
.then((response: SPHttpClientResponse) => { debugger;
response.json().then((json: any) => { debugger;
for(let i=0;i<json.value.length;i++){debugger; // json.value cannot read property , .value undefined
this.ppl.push({
name:json.value[i].PreferredName,
jobtitle:json.value[i].JobTitle,
workemail:json.value[i].WorkEmail,
pictureurl:json.value[i].PictureURL,
});
// codes continue...
I found that its a query so i must use
this.props.spHttpClient.get(url, SPHttpClient.configurations.v1, opt).then(response=>{
response.json().then(res=>{
let result = res.PrimaryQueryResult.RelevantResults.Table.Rows;
I can get
0: {Key: "RowLimit", Value: "60", ValueType: "Edm.Int32"}
1: {Key: "SourceId", Value: "b09a7990-05ea-4af9-81ef-edfab16c4e31", ValueType: "Edm.Guid"}
2: {Key: "CorrelationId", Value: "e9c7339f-e0fd-b000-e515-bff3355a8995", ValueType: "Edm.Guid"}
3: {Key: "EnableInterleaving", Value: "true", ValueType: "Edm.Boolean"}
4: {Key: "IsMissingUnifiedGroups", Value: "false", ValueType: "Edm.Boolean"}
5: {Key: "Constellation", Value: "i4302D", ValueType: "Edm.String"}
6: {Key: "MultiGeoSearchStatus", Value: "Full", ValueType: "Edm.String"}
7: {Key: "IsPartial", Value: "false", ValueType: "Edm.Boolean"}
8: {Key: "InternalRequestId", Value: "fa2dfdc9-e705-40e3-a99e-468cedbe7d4a", ValueType: "Edm.String"}
9: {Key: "SerializedQuery", Value: "<Query Culture="en-US" EnableStemming="True" Enabl…070cd" KeywordType="True" HiddenConstraints="" />", ValueType: "Edm.String"}
length: 10
but it no primary data result. if I append the link it shows in the browser What is the solution?

