【发布时间】:2018-01-05 04:26:56
【问题描述】:
我配置了我的 eslint,因此它根据需要使用箭头体样式:
arrow-body-style: ["error", "as-needed"]
但由于某种原因,我在下面收到错误消息。
router.get('/', (req, res, next) => {
Product.find({})
.select('name price _id')
.then(items => {
const response = {
count: items.length,
products: items.map(item => { // eslint points the error here
return {
name: item.name,
price: item.price,
_id: item._id,
request: {
type: 'GET',
url: `http://localhost:3000/products/${item._id}`
}
};
})
};
res.status(200).json(response);
})
.catch(error => {
console.log(error);
res.status(500).json({ message: 'Server error' });
});
});
我应该如何重写我的代码?
【问题讨论】:
标签: javascript eslint