Get operation using SP Http Client
try { | |
let spHttpClient : SPHttpClient = context.spHttpClient; | |
let url = `${context.pageContext.web.absoluteUrl}/_api/web/lists/GetByTitle('${listTitle}')/Items?$select=Author/EMail,*&$expand=Author&$filter=Author/EMail eq 'XYZ@xyz.com'`; | |
spHttpClient.get(url, SPHttpClient.configurations.v1).then((response : SPHttpClientResponse) => { | |
if(response.ok) | |
{ | |
response.json().then((responseJson : any) => { | |
console.log(responseJson); | |
if (this.isValidObject(responseJson) && responseJson.value.length !== 0) { | |
resolve({ | |
associatedItem: responseJson.value[0] | |
}); | |
} else { | |
resolve({ | |
associatedItem: null | |
}); | |
} | |
}); | |
} | |
}); | |
} catch (error) { | |
throw (error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment