I'm using latest version of node but when i try using spread operator babel raise an 'unexpected' token even after i install @babel/plugin-proposal-object-rest-spread
Items = () => {
return Item.find().then( items => {
return items.map( item => {
return {
...item._doc,
_id: item.id,
date: new Date(item.date).toISOString()
};
})
}).catch(e => {
throw e
})
To make support of spread operator you need to install transform-object-rest-spread
plugin on your base project
npm install --save-dev babel-plugin-transform-object-rest-spread
// or
yarn add babel-plugin-transform-object-rest-spread --dev
and then create a .babelrc file in your project directory
{
"plugins": ["transform-object-rest-spread"]
}
if you have already then add this plugin like this
{
"plugins": ["XXX", "YYY", .... ,"transform-object-rest-spread"]
}
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.