Skip to content

Instantly share code, notes, and snippets.

@koltyakov
Last active September 9, 2016 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koltyakov/bbbade9d8fb1398a648c5c7bdc192cd8 to your computer and use it in GitHub Desktop.
Save koltyakov/bbbade9d8fb1398a648c5c7bdc192cd8 to your computer and use it in GitHub Desktop.
PnP-JS-Core
$pnp.sp.web
.lists.getByTitle('ListTitle').items
.get()
.then(function(items) {
// all items are in the `items` array
});
var batchResults = [];
var batch = new $pnp.sp.createBatch();
$pnp.sp.web.getList('/sites/dev01/lists/custom01').items.inBatch(batch).get().then(function(d) {
batchResults.push({
custom01: d
});
});
$pnp.sp.web.getList('/sites/dev01/lists/custom02').items.inBatch(batch).get().then(function(d) {
batchResults.push({
custom02: d
});
});
for (var i = 0, len = 10; i < len; i += 1) {
$pnp.sp.web.getList('/sites/dev01/lists/custom03').inBatch(batch).items.add({
Title: 'Item ' + i
});
}
batch.execute().then(function() {
console.log("All is done!", batchResults);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment