26 lines
704 B
JavaScript
26 lines
704 B
JavaScript
const axios = require('axios');
|
|
const { logger } = require('../util/logger');
|
|
|
|
async function getDetails(customerNo) {
|
|
try {
|
|
const response = await axios.get(
|
|
'http://localhost:8686/kccb/cbs/custInfo/details',
|
|
{ params: { stcustno: customerNo } }
|
|
);
|
|
const details = response.data;
|
|
const processedDetails = details.map((acc) => ({
|
|
...acc,
|
|
activeAccounts: details.length,
|
|
cifNumber: customerNo,
|
|
}));
|
|
return processedDetails;
|
|
} catch (error) {
|
|
logger.error('while fetching customer details', error);
|
|
throw new Error(
|
|
'API call failed: ' + (error.response?.data?.message || error.message)
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = { getDetails };
|