Optimize database calls across multiple components by implementing Promise.all for parallel fetching of data, enhancing performance and reducing loading times.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m40s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m40s
This commit is contained in:
@@ -68,18 +68,22 @@ export default function FeedbackModal({
|
||||
if (!eventId) return;
|
||||
|
||||
try {
|
||||
// Récupérer l'événement
|
||||
const eventResponse = await fetch(`/api/events/${eventId}`);
|
||||
// Paralléliser les appels API
|
||||
const [eventResponse, feedbackResponse] = await Promise.all([
|
||||
fetch(`/api/events/${eventId}`),
|
||||
fetch(`/api/feedback/${eventId}`),
|
||||
]);
|
||||
|
||||
if (!eventResponse.ok) {
|
||||
setError("Événement introuvable");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const eventData = await eventResponse.json();
|
||||
setEvent(eventData);
|
||||
|
||||
// Récupérer le feedback existant si disponible
|
||||
const feedbackResponse = await fetch(`/api/feedback/${eventId}`);
|
||||
// Traiter le feedback
|
||||
if (feedbackResponse.ok) {
|
||||
const feedbackData = await feedbackResponse.json();
|
||||
if (feedbackData.feedback) {
|
||||
|
||||
Reference in New Issue
Block a user