binaryminds/react-native-sse

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

Closed this issue · 1 comments

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.');
});`

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.