AI-Voice-Agent-Node/controllers/apiController.js
2025-05-27 21:06:13 +05:30

29 lines
722 B
JavaScript

const { fetchContacts, fetchCallList } = require('../services/apiService');
async function getContacts(req, res) {
try {
const data = await fetchContacts();
res.json(data);
} catch (err) {
res.status(500).json({ error: err.message });
}
}
async function getCallList(req, res) {
const { assignedTo,call_id } = req.body || {};
if (!assignedTo && !call_id) {
return res.status(400).json({ error: "Missing assignedTo or call_id" });
}
try {
const data = await fetchCallList({assignedTo,call_id});
res.json(data);
} catch (err) {
res.status(500).json({ error: err.message });
}
}
module.exports = { getContacts, getCallList };