0

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;

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.