async nextInvocation()

in src/RAPIDClient.js [124:157]


  async nextInvocation() {
    if (this.useAlternativeClient) {
      const options = {
        hostname: this.hostname,
        port: this.port,
        path: '/2018-06-01/runtime/invocation/next',
        method: 'GET',
        agent: this.agent,
      };
      return new Promise((resolve, reject) => {
        let request = this.http.request(options, (response) => {
          let data = '';
          response
            .setEncoding('utf-8')
            .on('data', (chunk) => {
              data += chunk;
            })
            .on('end', () => {
              resolve({
                bodyJson: data,
                headers: response.headers,
              });
            });
        });
        request
          .on('error', (e) => {
            reject(e);
          })
          .end();
      });
    }

    return this.nativeClient.next();
  }