From ccb4375eb29f8aa76725ddc6224d16ec134278c6 Mon Sep 17 00:00:00 2001 From: Wout Mertens Date: Wed, 21 Feb 2018 13:30:17 +0100 Subject: [PATCH] Add async/await example --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 7eda99e..fd76a03 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,16 @@ sprLib.user().info() .catch(errMsg => console.error(errMsg)); ``` +You can also use the async/await syntax (available in recent browsers and Node.JS 8.6+, or via transpiling with BabelJS): +```javascript +const infoGetter = async () => { + // EX: Get the current user's ID, then get their Tasks + const objUser = await sprLib.user().info(); + const arrItems = await sprLib.list('Tasks').getItems({ queryFilter:'Owner/Id eq ' + objUser.Id }); + console.log("Current user's Tasks = " + arrItems.length); +} +``` ************************************************************************************************** # Installation