Created
May 6, 2019 21:26
-
-
Save AsishP/5967008fec6481cf0aeeeebb3fb6dc77 to your computer and use it in GitHub Desktop.
Get operation using SP Http Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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