lib/fetchStreamReadable.js
/**
   * Make a streaming query to the Devo API.
   *
   * @param {Object} options An object with method, body and headers.
   * @param {Object} callbacks An object with attributes for callbacks:
   *  - meta: receives headers.
   *  - data: receives each row of data.
   *  - error: receives any errors.
   *  - done: optional, invoked after finishing parsing.
   */
Make a streaming query to the Devo API.
@param {Object} options An object with method, body and headers.
@param {Object} callbacks An object with attributes for callbacks:
- meta: receives headers.
- data: receives each row of data.
- error: receives any errors.
- done: optional, invoked after finishing parsing.
Make a streaming query to the Devo API . @param { Object } options An object with method body and headers . @param { Object } callbacks An object with attributes for callbacks : - meta : receives headers . - data : receives each row of data . - error : receives any errors . - done : optional invoked after finishing parsing .
stream(options, callbacks) {
    this._request = this._fetchMethod(options.url, {
      method: options.method,
      withCredentials: true,
      headers: buildHeaders(options.headers),
      body: JSON.stringify(options.body)
    })
      .then(response => response.body)
      .then(rs => {
        this._reader = rs.getReader();
        const request = this;
        return new ReadableStream({
          start() {
            return processStream(request._reader, callbacks);
          }
        })
      })
      .catch((e) => console.error('error requesting:', e));
    return this;
  }
stream ( options , callbacks ) { this . _request = this . _fetchMethod ( options . url , { method : options . method , withCredentials : true , headers : buildHeaders ( options . headers ) , body : JSON . stringify ( options . body ) } ) . then ( response => response . body ) . then ( rs => { this . _reader = rs . getReader ( ) ; const request = this ; return new ReadableStream ( { start ( ) { return processStream ( request . _reader , callbacks ) ; } } ) } ) . catch ( ( e ) => console . error ( 'error requesting:' , e ) ) ; return this ; }
Make a streaming query to the Devo API.
Make a streaming query to the Devo API .