Update frontend/src/App.js
Browse files- frontend/src/App.js +6 -6
frontend/src/App.js
CHANGED
@@ -30,7 +30,7 @@ function App() {
|
|
30 |
// Fonction pour récupérer les conversations depuis l'API
|
31 |
const fetchConversations = async () => {
|
32 |
try {
|
33 |
-
const response = await fetch('
|
34 |
credentials: 'include', // Important pour envoyer les cookies
|
35 |
});
|
36 |
|
@@ -56,7 +56,7 @@ function App() {
|
|
56 |
// Fonction pour charger les messages d'une conversation sélectionnée
|
57 |
const loadConversationMessages = async (conversationId) => {
|
58 |
try {
|
59 |
-
const response = await fetch(
|
60 |
credentials: 'include',
|
61 |
});
|
62 |
|
@@ -129,7 +129,7 @@ function App() {
|
|
129 |
setActiveConversationId(conversationId);
|
130 |
|
131 |
// IMPORTANT: Enregistrer le message utilisateur une fois l'ID disponible
|
132 |
-
await fetch(
|
133 |
method: 'POST',
|
134 |
headers: { 'Content-Type': 'application/json' },
|
135 |
credentials: 'include',
|
@@ -146,7 +146,7 @@ function App() {
|
|
146 |
} else {
|
147 |
// Sauvegarder le message utilisateur pour une conversation existante
|
148 |
try {
|
149 |
-
await fetch(
|
150 |
method: 'POST',
|
151 |
headers: { 'Content-Type': 'application/json' },
|
152 |
credentials: 'include',
|
@@ -168,7 +168,7 @@ function App() {
|
|
168 |
if (!conversationId) return;
|
169 |
|
170 |
try {
|
171 |
-
await fetch(
|
172 |
method: 'POST',
|
173 |
headers: {
|
174 |
'Content-Type': 'application/json',
|
@@ -198,7 +198,7 @@ function App() {
|
|
198 |
const handleLogout = async () => {
|
199 |
try {
|
200 |
// Appeler l'API de déconnexion
|
201 |
-
await fetch('
|
202 |
method: 'POST',
|
203 |
credentials: 'include',
|
204 |
});
|
|
|
30 |
// Fonction pour récupérer les conversations depuis l'API
|
31 |
const fetchConversations = async () => {
|
32 |
try {
|
33 |
+
const response = await fetch('/api/conversations', {
|
34 |
credentials: 'include', // Important pour envoyer les cookies
|
35 |
});
|
36 |
|
|
|
56 |
// Fonction pour charger les messages d'une conversation sélectionnée
|
57 |
const loadConversationMessages = async (conversationId) => {
|
58 |
try {
|
59 |
+
const response = await fetch(`/api/conversations/${conversationId}/messages`, {
|
60 |
credentials: 'include',
|
61 |
});
|
62 |
|
|
|
129 |
setActiveConversationId(conversationId);
|
130 |
|
131 |
// IMPORTANT: Enregistrer le message utilisateur une fois l'ID disponible
|
132 |
+
await fetch(`/api/conversations/${conversationId}/messages`, {
|
133 |
method: 'POST',
|
134 |
headers: { 'Content-Type': 'application/json' },
|
135 |
credentials: 'include',
|
|
|
146 |
} else {
|
147 |
// Sauvegarder le message utilisateur pour une conversation existante
|
148 |
try {
|
149 |
+
await fetch(`/api/conversations/${conversationId}/messages`, {
|
150 |
method: 'POST',
|
151 |
headers: { 'Content-Type': 'application/json' },
|
152 |
credentials: 'include',
|
|
|
168 |
if (!conversationId) return;
|
169 |
|
170 |
try {
|
171 |
+
await fetch(`/api/conversations/${conversationId}/messages`, {
|
172 |
method: 'POST',
|
173 |
headers: {
|
174 |
'Content-Type': 'application/json',
|
|
|
198 |
const handleLogout = async () => {
|
199 |
try {
|
200 |
// Appeler l'API de déconnexion
|
201 |
+
await fetch('/api/logout', {
|
202 |
method: 'POST',
|
203 |
credentials: 'include',
|
204 |
});
|