Skip to content

Commit

Permalink
Modify example code to work out of the box
Browse files Browse the repository at this point in the history
When testing the old example code I would get the following error:

const drives = await drivelist.list();
               ^^^^^
SyntaxError: await is only valid in async function

I have modified the example code so you can cut, paste and run without error.
  • Loading branch information
camow7 authored Mar 4, 2020
1 parent a76b9bf commit 0a921d3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ Examples (the output will vary depending on your machine):
```js
const drivelist = require('drivelist');

const drives = await drivelist.list();
console.log(drives);
getDrives();

async function getDrives () {
const drives = await drivelist.list();
console.log(drives);
}
```

***
Expand Down Expand Up @@ -176,10 +180,14 @@ Documentation
```js
const drivelist = require('drivelist');

const drives = await drivelist.list();
drives.forEach((drive) => {
console.log(drive);
});
getDrives();

async function getDrives () {
const drives = await drivelist.list();
drives.forEach((drive) => {
console.log(drive);
});
}
```

Tests
Expand Down

0 comments on commit 0a921d3

Please sign in to comment.