Skip to content

JSNLog Not resetting xhr object in React native #75

@msreddy09

Description

@msreddy09

I have written code as below in react native. But I am seeing only one message(very first message) in the server.

Any consecutive requesting fails with [Error: Cannot open, already sending]

import {JL} from 'jsnlog'

 var app = JL.createAjaxAppender("appender").setOptions({     
     'url': 'http://127.0.0.1:8080/log'
 });

 JL().setOptions({
     "appenders": [app]
 });


class App extends React.Component {
    componentDidMount () {
      JL().info('Application started')
      JL()..debug('Application started with no config')
    }
    render() {
        return(
            <div className ="container-fluid">
               <Header />
               <Switch>
                    <Route exact path ="/" component ={HomePage} />
                    <Route  path ="/about" component ={AboutPage} />
                    <Route  path ="/courses" component ={CoursesPage} />
                    <Route  component={PageNotFound} />
               </Switch>
              
            </div>
        )
    }
}

export default App;

Temporarily, we tried re-initialized XHR object inside the

  AjaxAppender.prototype.sendLogItemsAjax = function (logItems, successCallback) {

        this.xhr = JL._createXMLHttpRequest()
    // rest of the code
}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions