In this err.length code always returns []. Where am I going wrong?
err.length does not wait for map result
router.post('/add', authSigs, async (req, res) => {
const nds = req.body.nds
const split = nds.split('\n')
const err = []
await split.map(async item => {
let sub = item.substr(0, 7)
const checkModel = await modelSerial.findOne({
'modelNds': sub
})
if (!checkModel) err.push(item)
})
if (err.length > 0) return res.status(400).send({error: 'Invalid'})
return res.status(200).send()
})