我試圖調用此函數的Postgres core.get_age(BIGINT)在我queries.js在調用API節點
function getAge(req, res, next){
var customer_id= parseInt(req.params.customer_id);
db.one('SELECT * FROM core.get_age($1)', customer_id)
.then(function(data){
res.status(200)
.json({
status: 'success',
data : data,
message: "Retrieved Age"
});
})
}
任何我在index.js路線一個Postgres數據庫功能
router.get('/api/age/:customer_id', db.getAge);
當我在POSTMAN中致電http://localhost:8080/api/age/10時,我得到404錯誤。
出了什麼問題?這是我想要調用Postgres函數的第一個實例()。只是想找回Postgres的表select * from
this.this表的作品,但與功能我得到這個404
原因是你沒有使用承諾的權利。必須始終提供'.catch'處理程序。這樣你可以立即知道問題在哪裏。 –