Reputation: 35
I don't know what is the problem..
This code has 'SyntaxError: Unexpected identifier' err in line 14.
What is the problem between query and database pool?
const express = require('express');
const router = express.Router();
const request=require('async');
const db = require('../../module/pool.js');
router.get('/:user_id', (req, res) => {
try {
if(!(req.params.user_id)){
res.status(403).send({
message : "no user_id input"
});
} else {
let query = 'select A.store_name, A.store_img, count(B.store_idx) as review_cnt from board.store A Left Join board.review B On A.store_idx is B.store_idx where store_idx is (select A.store_idx from bookmark where user_id = ?)';
let bookmarks = await db.queryParam_Arr(query, [req.params.user_id]);
if (!bookmarks) {
res.status(500).send({
msg : "No Bookmarks"
});
} else {
res.status(200).send({
msg : "Successfully get list",
list : bookmarks
});
}
}
} catch (err) {
console.log(err);
res.status(500).sen ({
msg : "syntax err"
});
}
});
module.exports = router;
Upvotes: 0
Views: 125
Reputation: 312
You are using await
(line 14) but the function is not async
.
just updated your route definition in this way
router.get('/:user_id', async(req, res) => {
// your code
});
and it should work properly.
Upvotes: 1