Spaces:
Runtime error
Runtime error
File size: 792 Bytes
de234b1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import axios from 'axios';
const handleSendEmail = async (email) => {
try {
// Fetch chatHistory from localStorage
const storedChatHistory = localStorage.getItem('chatHistory');
// If it doesn't exist or is empty, return
if (!storedChatHistory || storedChatHistory.length === 0) {
console.error("Chat history is empty.");
return;
}
const response = await axios.post('http://localhost:5000/exportChat', {
email: email,
chatHistory: JSON.parse(storedChatHistory) // Convert the stringified JSON to an object
});
console.log(response.data);
} catch (error) {
console.error("Error sending email:", error);
}
};
export default handleSendEmail; |