const axios = require('axios');
exports.getDashboard = async (req, res) => {
try {
const accessToken = req.cookies.accessToken;
const response = await axios.get(`${process.env.API_URL}/customers`, {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
// const cookies = req.headers.cookie;
// const response = await axios.get(`${process.env.API_URL}/customers`, {
// headers: {
// Cookie: cookies
// }
// });
const data = response.data;
res.render('dashboard', {
title: 'Dashboard',
protectedData: data,
error: null
});
} catch (error) {
console.error('Error fetching protected data:', error);
res.render('dashboard', {
title: 'Dashboard',
protectedData: null,
error: 'Error fetching protected data'
});
}
};