employeeData.js
function getById(id) {
return dbPromise.one(); // using pg-promise
}
employeeService.js
function getInfoById(id) {
return employeeData.getXYZ(id); // purposefully calling a function that does not exist in the employeeData module
}
employeeApi.js // Express route function
const getInfoById = (req, res) {
employeeService.getInfoById(123)
.then(response => {
res.json(response);
})
.catch(err => {
res.json(err); // this is not being triggered
});
}
In the employeeService
above I purposefully mis-typed the function name and I think it should throw an undefined error for calling a function getXYZ
that does not exist in the employeeData.js
. However, the catch block in employeeApi.js
is not called.
Can you suggest what I might be missing here?