Search code examples
cyclejs

Make an http request on document load using cyclejs


How do I make an http request to a webservice on document load using cyclejs? The examples cover reacting to user input and don't meet my needs.


Solution

  • You may try to create a request stream and pass it to the HTTPDriver. For example:

    const request$ = Rx.Observable.just({
        url: 'http://www.google.com',
        method: 'GET'
    });
    

    Then:

    return {
      HTTP: request$
    };