Sails version:1.0.1
Node version:9.10.1
NPM version:5.6.0
DB adapter name: N/A
DB adapter version: N/A
Operating system:OS X
@danil-z Thanks for posting, we'll take a look as soon as possible.
For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.
This is not related to the sails console, the await operator is valid only in async functions , take a look here.
Thanks @hamzaOp! @danil-z, as of right now the Node REPL doesn't support await outside of an async function (although interestingly enough Chrome dev tools do!). Since sails console uses the Node REPL, it has this same constraint. You can see the discussion about this in the Node repo itself here.
In the meantime, you can run async code in the console by wrapping it in a self-calling async function, e.g.:
(async () => {
console.log(await User.find({ name: 'joe' }));
})()
Most helpful comment
Thanks @hamzaOp! @danil-z, as of right now the Node REPL doesn't support
awaitoutside of an async function (although interestingly enough Chrome dev tools do!). Sincesails consoleuses the Node REPL, it has this same constraint. You can see the discussion about this in the Node repo itself here.In the meantime, you can run async code in the console by wrapping it in a self-calling async function, e.g.: