Skip to content

Commit

Permalink
fix: error logging and endpoint adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
berenteb committed Mar 6, 2024
1 parent 98d408a commit cb6c34d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hooks/use-messaging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import axios from 'axios';
import axios, { isAxiosError } from 'axios';
import { useEffect, useState } from 'react';

import { QNA_API_BASE_URL } from '../config/env.config';
Expand Down Expand Up @@ -56,7 +56,12 @@ export function useMessaging() {
updateMessage({ ...newMessage, status: 'sent' });
addAnswer('Kérdésed megkaptuk és moderálás után a felolvasandó kérdések közé kerül. Köszönjük!');
})
.catch(() => {
.catch((e) => {
if (isAxiosError(e)) {
console.error('Error sending question', e.response?.data);
} else {
console.error('Error sending question', e);
}
updateMessage({ ...newMessage, status: 'error' });
});
};
Expand All @@ -69,7 +74,7 @@ export function useMessaging() {
}

async function sendMessage(content: string, presentationId: string, userId: string) {
return await axios.post(`${QNA_API_BASE_URL}/api/presentation/${presentationId}/questions`, {
return await axios.post(`${QNA_API_BASE_URL}/api/presentation/${presentationId}/question`, {
content,
userId,
});
Expand Down

0 comments on commit cb6c34d

Please sign in to comment.