У меня есть два запроса mysql для запуска.Я могу запустить только второй запрос на основе результата, который я получил от первого запроса.Моя проблема в том, что я не знаю, как передать результат в качестве параметра во второй запрос
router.post('/member/add', (req, res)=>{
let ins_company = req.body.ins_company
let firstname = req.body.firstname
let othernames = req.body.othernames
let surname = req.body.surname
let member_no = req.body.new_member_no
let status = req.body.card_status
let card_pin = req.body.card_pin
let join_date = req.body.join_date_now
let date_of_birth = req.body.dateofbirth
let sex = req.body.patient_sex
let telephone_no = req.body.tel
let nationality = req.body.patient_nationality
let employer = req.body.employer
let employer_id = req.body.employer_id
let health_plan = req.body.health_plan
let email = req.body.email
let relationship = req.body.relationship
let picpath = req.body.filepath0
let member_type = req.body.member_type
let rx_member_id = req.body.rx_member_id
let member_plan_id = 'SLB Medical Plan'
let result
result = db.query("SELECT * FROM company_plan WHERE PlanID = ?",[member_plan_id],(err,row,fields)=>{
if(err){
console.log("Some errors "+ err)
res.end()
return
}
res.end()
return
let member_plan = row[0].Plan
const queryString = "INSERT INTO patient_info_registration(ins_company,member_plan,surname,firstname) VALUES(?,?,?,?)"
db.query(queryString, [
ins_company,
member_plan,
surname,
firstname
], (err,row,fields)=>{
if(err){
console.log("Some errors "+ err)
res.end()
return
}
res.json(row);
})
})
})
})
module.exports = router
Я хочу иметь возможность передать переменную member_plan = row [0] .Plan для следующего запроса.