Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it ok to have two responses from server?

there.
I using getStream chat service in React web app and i noticed one thing.
After changing a channel i have two response from server one 201 and another 200.

201-xhr

and

200-Preflight

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Sometimes i may have only one 201-xhr
I was wondering could it be the issue on my app, that i make two calls or it’s normal?

>Solution :

An HTTP request only has one response.

Your code is requesting once, but HTTP-wise, two requests are sent (giving you a total of two responses).

This happens because there’s an initial request (preflight) which is done behind the scenes by the browser just to check if the CORS protocol is understood and if the server will allow your request.

You can see more details here.

Once the browser knows about the CORS options, it might decide not to request them for a while (which is why sometimes you see only 1 request/response in the network inspector).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading