Я добавляю другой параметр к моему текущему запросу в моем маршрутизаторе.
Но я получаю эту ошибку:
TypeError: cb не является функцией
в Query.client.запрос [как обратный вызов]
Это мой код:
// old code with just distance params that works
...
const express = require('express');
const pool = require('../modules/pool');
const router = express.Router();
router.get('/:lat/:lon', (req, res) => {
console.log('location GET local route');
let queryText = `SELECT *, distance($1, $2, location.latitude, location.longitude) as distance FROM location ORDER BY distance ;`
pool.query(queryText, [req.params.lat, req.params.lon]).then((result) => {
res.send(result.rows);
// console.log(result.rows)
}).catch((error) => {
console.log(error);
res.sendStatus(500);
});
});
module.exports = router;
// this is the current router with the error.
const express = require('express');
const pool = require('../modules/pool');
const router = express.Router();
router.get('/:lat/:lon/:type', (req, res) => {
console.log('location GET local route');
let queryText = `SELECT *, distance($1, $2, location.latitude, location.longitude) as distance FROM location ORDER BY distance WHERE "type" = $1;;`
pool.query(queryText, [req.params.lat, req.params.lon], [req.params.type])// erroring here
.then((result) => {
res.send(result.rows);
// console.log(result.rows)
}).catch((error) => {
console.log(error);
res.sendStatus(500);
});
});
module.exports = router;