binaryminds / react-native-sse

Event Source implementation for React Native. Server-Sent Events (SSE) for iOS and Android 🚀
https://www.npmjs.com/package/react-native-sse
MIT License
174 stars 27 forks source link

{"message": "", "type": "error", "xhrState": 4, "xhrStatus": 500} #34

Closed umairkhan89 closed 4 months ago

umairkhan89 commented 6 months ago

Getting this error {"message": "", "type": "error", "xhrState": 4, "xhrStatus": 500}

const es = new EventSource(${BASE_URL}${ASK_QUESTION}/`, { body: { chatId: chatId, prompt: prompt, }, method: 'POST', headers: { 'Content-Type': 'text/event-stream' }, debug: true, pollingInterval: 10000, timeoutBeforeConnection: 10000, withCredentials: true, });

console.log('es', es); es.addEventListener('open', (event) => { console.log('Open SSE connection.', event); });

es.addEventListener('message', (event) => { console.log('New message event:', event.data); });

es.addEventListener('error', (event) => { if (event.type === 'error') { console.error('Connection error:', event); } else if (event.type === 'exception') { console.error('Error:', event.message, event.error); } });

es.addEventListener('close', (event) => { console.log('Close SSE connection.'); });`

EmilJunker commented 6 months ago

The backend is responding with a HTTP status 500 (internal server error) at the requested endpoint. The issue is not with the client or with the react-native-sse library.