简体   繁体   中英

sailsjs - unexpected token for spread operator (…)

So I downloaded sailsjs and using it to develop my API. All ES6 features work fine, but when I use the spread operator it throw an unexpected token error

const a = {test: 'test'};
const b = { something: 'something', ...a };

I am totally new to nodejs. If the answer to this is adding some packages (babel or something), then would appreciated some detailed explanation of steps for a newbie. And also, how would I deploy (I am using circleci) that extra build step?

Spread in object literals is currently not supported by nodejs, because it is a proposal. It works in the jsfiddle.net because it is supported by Chrome and Firefox, although it is marked as an error by the parser. For more info see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM