title: SSE in React native
body: <p>how can i use <strong>SSE</strong> (server sent events) in <strong>react native</strong> ?, I have not been able to get it to work,</p>
  <p>I try with <a href="https://github.com/jordanbyron/react-native-event-source" rel="nofollow noreferrer">https://github.com/jordanbyron/react-native-event-source</a> and <a href="https://github.com/JonnyBGod/react-native-eventsource" rel="nofollow noreferrer">https://github.com/JonnyBGod/react-native-eventsource</a> but dont work,</p>
  <p>My backend api is with spring webflux</p>
  <pre><code>import React, {memo, useState, useEffect} from 'react';
  import {Navigation} from '../types'
  import AppBarHeader from &quot;../components/AppBarHeader&quot;;
  import RNEventSource from 'react-native-event-source'
  
  type Props = {
      navigation: Navigation;
  };
  
  const MessageScreen = ({navigation}: Props) =&gt; {
  
      const getMessages = (email: string) =&gt; {
  
          console.log('obteniendo evt source')
  
          const options = { headers: { Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJ1c2VyQHRlc3QuY29tIiwic2NvcGUiOlsicmVhZCIsIndyaXRlIl0sIlVTRVJfSUQiOiI1ZWViYzY4ZmIyMDBlNTAyMjIyNTcyYTEiLCJleHAiOjE1OTI3MDQ0MzAsIkxBU1RfTkFNRSI6IlJvZHJpZ3VleiIsIkVNQUlMIjoidXNlckB0ZXN0LmNvbSIsImF1dGhvcml0aWVzIjpbIlJPTEVfVVNFUiJdLCJqdGkiOiJiNjE3YzE0My04MjhjLTQ3M2ItOGJkNC00MWQ5MmUwN2FkNjUiLCJGSVJTVF9OQU1FIjoiSnVhbiIsImNsaWVudF9pZCI6Im1lZGljYXBwIn0.fNDzx8sjOt1YxwQoxNdlBqXZ6XcMhXGxZQNktAHxmWw'}};
  
          const eventSource = new RNEventSource('http://localhost:8080/chat', options);
  
          eventSource.addEventListener('message', (data) =&gt; {
              console.log(data.type); // message
              console.log(data.data);
          });
  
      }
  
      getMessages('das');
  
      return (
          &lt;&gt;
              &lt;AppBarHeader navigation={navigation} title={'Chat'} /&gt;
  
          &lt;/&gt;
      );
  };
  
  export default memo(MessageScreen);
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ZmpY9.png" rel="nofollow noreferrer">Console log</a></p>
  <p>Thanks</p>