不确定我是否在代码下面丢失了任何东西是否抛出了错误映射,这不是函数吗?
有什么更好的方法可以使代码达到结果?
main.js
const errorCodes = [99,890];
const drug = [{
"isBrand": true,
"drugName": "Lipitor",
"specialtyPrice": {}
},
{
"isBrand": false,
"drugName": "Atorvastatin Calcium",
"drugStrength": "80mg",
"drugForm": "Tablet",
"mailPrice": {
"totalQuantity": 90,
"rejectMessage": [{
"settlementCode": "99",
"settlementDesc": "Sorry, the system is temporarily:Lo sentimos,Intente(Código de error 85)"
}]
},
"retailPrice": {
"totalQuantity": 30,
"rejectMessage": [{
"settlementCode": "99",
"settlementDesc": "Sorry, the system is temporarily:Lo sentimos,Intente(Código de error 85)"
}]
},
"specialtyPrice": {}
}
];
const filteredPrices = drug.map(item => {
const errorCodes = drugPriceErrors;
const pricePath = ['mailPrice.rejectMessage', 'retailPrice.rejectMessage'];
_.forEach(pricePath, function (path) {
const rejectMsg = _.get(item, path);
const hasCode = rejectMsg && rejectMsg.find(i => !!~errorCodes.indexOf(+i.settlementCode));
hasCode && delete item[path.split('.').shift()];
});
return item;
});
错误:
TypeError: drug.map is not a function