forked from evs-broadcast/node-emberplus
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I'm probably doing something fundamentally wrong but the example code appears to throw await promise errors as documented below. All advice welcomed.
Steps to reproduce:
Install npm package:
npm i node-emberplus
Create file from example code:
const {EmberClient, EmberClientEvent, LoggingService} = require('node-emberplus');
const client = new EmberClient({host: '192.168.1.2', port: 9000, logger: new LoggingService(5)});
client.on(EmberClientEvent.ERROR, e => {
console.log(e);
});
await client.connectAsync();
// Get Root info
await client.getDirectoryAsync();
// Get a Specific Node
let node: TreeNode = await client.getElementByPathAsync("0.0.2");
console.log(node);
// Get a node by its path identifiers
node = await client.getElementByPathAsync("path/to/node");
console.log(node);
// Expand entire tree
try {
await client.expandAsync();
}catch(e) {
console.log(e.stack);
};
Run:
[user-hidden]% node index.js
[full-path-hidden]/lawo-node-ember-plus/index.js:7
await client.connectAsync();
^^^^^
SyntaxError: await is only valid in async functions and the top level bodies of modules
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1027:15)
at Module._compile (node:internal/modules/cjs/loader:1063:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v17.8.0
Metadata
Metadata
Assignees
Labels
No labels