const axios = require('../axios')

const atinaApi = process.env.ATINA_FE_API || '167.172.170.78';

module.exports = async (req, res) => {
    // Assuming the ID is provided as a parameter
    const { id } = req.params;
    const { jwttoken, entidad } = req.headers

    return axios({
        method: 'get',
        headers: {
            jwttoken,
            entidad,
            Accept: 'application/xml'
        },
        url: `https://${atinaApi}:8082/api/consulta/ListaDE?mode=IDBaseDeDatos&id=${id}`,
        
    }).then(response => {
        // Set the response content type to XML
        res.set('Content-Type', 'application/xml');
        // Return the response from the API endpoint
        res.send(response.data);
    })
    .catch(error => {
        console.error(JSON.stringify(error.response.data));
        // Return any error that occurred during the request
        res.status(error.response.status).json({ ...error.response.data });
    });
    
}