Skip to content

Instantly share code, notes, and snippets.

@andrewconnell
Created March 8, 2015 16:49
Show Gist options
  • Select an option

  • Save andrewconnell/733337952613f55af34f to your computer and use it in GitHub Desktop.

Select an option

Save andrewconnell/733337952613f55af34f to your computer and use it in GitHub Desktop.
ADAL JS + Angular: SharePoint Service
/**
* Get all all lists in the target SharePoint site.
*
* @param sharePointSiteApiUrl {string} URL of the REST API endpoint of the SharePoint site.
* @returns {IPromise<adalO365CorsClient.shared.ISpList[]>} Collection of all the lists in the specified SharePoint
* site.
*/
public getAllLists(sharePointSiteApiUrl:string) {
var deferred = this.$q.defer();
var endpoint = sharePointSiteApiUrl + 'web/lists?'
+ '$select=Id,Title,DefaultView/ServerRelativeUrl'
+ '&$expand=DefaultView'
+ '&$orderby=Title';
// issue query for all sharepoint lists in specified site
//
// NOTE: because this is a cross domain REST call, the browser will first issue an HTTP OPTIONS request to check
// that the REST API supports CORS requests for specific HTTP methods
this.$http.get(endpoint, this.appSettings.defaultSharePointHttpGetOptions)
.then((result:shared.ISpListOdataResponse) => {
var lists:shared.ISpList[] = result.data.d.results;
deferred.resolve(lists);
});
return deferred.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment