-
Notifications
You must be signed in to change notification settings - Fork 39
React Native SSE is always moving to 'error' but the API is working in web SSE and postman #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Please pass the // Create the EventSource instance
const eventSource = new EventSource(
`${BaseURL}workspace/${slug}/stream-chat`,
{
+ debug: true,
method: 'POST',
headers: await baseHeaders(),
body: JSON.stringify({message, attachments}),
},
); |
Once I turn on the debug mode these are the debug logs I received
|
It's not entirely clear from the logs, but I suspect the headers react-native-sse is sending by default are causing the problem. There is an open pull request aimed at making the default headers optional: #51 @DeepikaSharma5 For now, you can try going to the node_modules/react-native-sse folder and removing lines 80 and 81 from the source code. react-native-sse/src/EventSource.js Lines 80 to 81 in d64b51a
|
Thank you. This helped me fix the issue. |
I am trying o implement react-native-sse in my react native application. I have converted the code from the web application which is already implemented using @microsoft/fetch-event-source. In there it is working without any issues.
But when I try to do the same implementation in react native app using react-native-sse it is always going to error. I wonder if I have missed anything or implemented anything wrong in the react-native code. I am passing all the values and necessary things as passed in the web application (values message and attachments are not empty and passing the value from props). I am new to sse and this is my first time implementing.
This is my coding for reference =>
If anyone can help me identify if I have done something wrong or may be I may need to make any changes in the server side?
In the react application, this is how it is implemented =>
},`
Any help would be really helpful as I am trying this for more than a week to identify what the issue is. As the react application is working, backend developer are not supporting to debug or change the code.
It is working fine in the postman too =>

The text was updated successfully, but these errors were encountered: