Currently, I am attempting to use a get request method within both Vue and Express in order to retrieve data based on my v-model.
Displayed below is the code where I am trying to send the data to Express.
getResult() {
axios
.get(
`${process.env.VUE_APP_API}/hospita/result/` +
{
hosp_name: "SAMPLE"
}
)
.then(res => console.log(res.data))
.catch(err => console.log(err));
}
Furthermore, here is the get request method responsible for receiving data from Vue.js.
router.get('/result/', (req, res) => {
const sql = "SELECT * FROM ND_HOSP WHERE hosp_ptype = 'h' AND hosp_name LIKE ?";
console.log(req.body)
myDB.query(sql, ['%' + req.body.hosp_name + '%'], (err, result) => {
if (err) {
console.log(err)
} else {
try {
res.send(result);
/* console.log(result) */
} catch (err) {
res.send(err)
}
}
})
})
Despite these efforts, an error message appears stating http://localhost:9002/hospita/result/[object%20Object]