web-app-temp / web_app /frontend /src /components /emailService.jsx
leothesouthafrican's picture
Initial commit on web_app_temp
de234b1
raw
history blame contribute delete
792 Bytes
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;