Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Commit

Permalink
Added async/await (Issue #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
GitBrent authored and GitBrent committed Feb 23, 2018
1 parent e39c42f commit 6341c1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**Implemented Enhancements:**
- Removed jQuery methods from sprestlib.js, reducing dependencies to zero!
- Add support for SP User Profile API [\#14](https://github.com/gitbrent/sprestlib/issues/14) ([ra6hi9](https://github.com/ra6hi9))
- Add async/await example [\#16](https://github.com/gitbrent/sprestlib/pull/16) ([wmertens](https://github.com/wmertens))

**Fixed Bugs:**

Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,15 @@ 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):
You can also use the native async/await syntax (available in recent browsers and Node.JS 8.6+, or via transpiling with BabelJS)
as async/await is built on JavaScript Promises.

```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);
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);
}
```

Expand Down

0 comments on commit 6341c1d

Please sign in to comment.