_post()

in src/RAPIDClient.js [169:200]


  _post(path, body, headers, callback) {
    let bodyString = _trySerializeResponse(body);
    const options = {
      hostname: this.hostname,
      port: this.port,
      path: path,
      method: 'POST',
      headers: Object.assign(
        {
          'Content-Type': 'application/json',
          'Content-Length': Buffer.from(bodyString).length,
        },
        headers || {},
      ),
      agent: this.agent,
    };
    let request = this.http.request(options, (response) => {
      response
        .on('end', () => {
          callback();
        })
        .on('error', (e) => {
          throw e;
        })
        .on('data', () => {});
    });
    request
      .on('error', (e) => {
        throw e;
      })
      .end(bodyString, 'utf-8');
  }