Tabnine Logo For Javascript
Response.on
Code IndexAdd Tabnine to your IDE (free)

How to use
on
function
in
Response

Best JavaScript code snippets using request.Response.on(Showing top 15 results out of 315)

origin: eashish93/imgsquash

request
  .get(url.href)
  .on('response', (resp) => {
    resp.on('data', (chunk) => {
      if(image.size > MAX_FILE_SIZE + 1024*10) {    // maxFileSize + 10KB padding.
        isMaxFileSizeExceed = true;
  .on('end', () => {
    if(isResponseSent) return;
    if(isMaxFileSizeExceed)
      .on('error', (err) => {
        log.error(err, 'Error uploading file');
        return errors.internalServer(res);
      })
      .on('finish', async () => {
        const metadata = await gcsFile.getMetadata();
        await gcsFile.makePublic();
origin: olami-developers/olami-api-quickstart-nodejs-samples

request.get({
    url: url,
  }, function(err, res, body) {
    if (err) {
      console.log(err);
    }
  }).on('response', function(response) {
    var bufferhelper = new BufferHelper();
    response.on('data', function(chunk) {
      bufferhelper.concat(chunk);
    });
    
    response.on('end', function() {
      var result = iconv.decode(bufferhelper.toBuffer(), 'UTF-8');

      console.log("---------- Test NLU API, api = "+ apiName +" ----------");
      console.log("Sending 'POST' request to URL : " + url);
      console.log("Result:\n" + result);
      console.log("------------------------------------------");
    });
  });
origin: braydonf/gpk

req.on('response', function (res) {
 var body = ''
 res.setEncoding('utf8')
 res.on('data', function (data) {
  body += data
 })
 res.on('end', function () {
  t.strictEqual(body, 'ok')
 })
origin: chill117/proxy-verifier

req.on('response', function(res) {

      res.setEncoding('utf8');

      var responseData = '';
      var status = res.statusCode;
      var headers = res.headers;

      res.on('data', function(chunk) {
        responseData += chunk;
      });

      res.on('end', function() {

        res.destroy();

        if (headers['content-type'] && headers['content-type'].indexOf('application/json') !== -1) {

          try {
            responseData = JSON.parse(responseData);
          } catch (error) {
            return done(error);
          }
        }

        done(null, responseData, status, headers);
      });
    });
origin: pd4d10/nn

async function fetchFromRemote(url, outputFileName) {
 // Fetch
 console.log(`Downloading ${url}`)

 await fs.ensureDir(path.parse(outputFileName).dir)
 await new Promise((resolve, reject) => {
  request(url)
   .on('response', res => {
    if (res.statusCode >= 400) {
     return reject(`${version} not found, please input a valid version`)
    }
    const len = parseInt(res.headers['content-length'], 10)

    bar = new ProgressBar('Downloading [:bar] :rate/bps :percent :etas', {
     width: 20,
     total: len,
     renderThrottle: 500,
    })

    res.on('data', chunk => {
     bar.tick(chunk.length)
    })
   })
   .on('error', reject)
   .on('end', resolve)
   .pipe(fs.createWriteStream(outputFileName))
 })
}
origin: iamport/iamport-rest-client-nodejs

.on('response', function(res){
 if( Resource.errorStates.indexOf(res.statusCode) >= 0 ) {
  var err = new Error(res.statusCode);
  reject(err);
 } else {
  res.on('data', function(body) {
   var result;
   try {
.on('error', reject);
origin: trygve-lie/circuit-b

const req = request(opts);
req.on('response', (res) => {
  if (res.statusCode !== 200) {
    resolve('http error');
  res.on('data', (chunk) => {
    data += chunk;
  });
  res.on('end', () => {
    resolve(data);
  });
});
req.on('error', (error) => {
  if (error.code === 'CircuitBreakerOpenException') {
    resolve('circuit breaking');
origin: pd4d10/nn

await new Promise((resolve, reject) => {
 request(url)
  .on('response', res => {
   const len = parseInt(res.headers['content-length'], 10)
   })
   res.on('data', chunk => {
    bar.tick(chunk.length)
   })
  })
  .on('error', reject)
  .on('end', resolve)
  .pipe(fs.createWriteStream(outputFileName))
})
origin: braydonf/gpk

})
server.on('clientError', function (err) {
 throw err
})
 req.on('response', function (res) {
  var body = ''
  res.setEncoding('utf8')
  res.on('data', function (data) {
   body += data
  })
  res.on('end', function () {
   t.strictEqual(body, 'ok')
  })
origin: TerriaJS/terriajs-server

httpStream.on('response', function(response) {
  var request = this, len = 0;
  convertStream(response, req, res, hint);
  response.on('data', function (chunk) {
    len += chunk.length;
    if (!abort && len > convert.maxConversionSize) {
  response.on('end', function() {
    console.log('Convert: received file of ' + len + ' bytes' + (abort ? ' (which we\'re discarding).' : '.'));
  });
origin: giscafer/Ponitor

.on('response', function(response) {
  response.setEncoding = 'utf8';
  response.on('data', function(chunk) {
    body.push(chunk);
    size += chunk.length;
  });
})
.on('error', function(err) {
  reject(err);
})
.on('end', function() {
  const bff = Buffer.concat(body, size);
  const text = iconv.decode(bff, 'GBK');
origin: braydonf/gpk

req.on('error', done)
req.on('response', function (res) {
 if (res.statusCode !== 200) {
  done(new Error(res.statusCode + ' status code downloading checksum'))
 res.on('data', function (chunk) {
  chunks.push(chunk)
 })
 res.on('end', function () {
  var lines = Buffer.concat(chunks).toString().trim().split('\n')
  lines.forEach(function (line) {
origin: olami-developers/olami-api-quickstart-nodejs-samples

    console.log(err);
}).on('response', function(response) {
  var bufferhelper = new BufferHelper();
  response.on('data', function(chunk) {
    bufferhelper.concat(chunk);
  });
  response.on('end', function() {
    var body = iconv.decode(bufferhelper.toBuffer(), 'UTF-8');
    var result = JSON.parse(body);
origin: olami-developers/olami-api-quickstart-nodejs-samples

    throw err;
}).on('response', function(response) {
  var body = "";
  response.on('data', function(data) {
      body += data;
  });
  response.on('end', function() {
    _this.cookies = response.headers['set-cookie'];
    console.log("\n----- Test Speech API, seq=nli,seg -----\n");
origin: giscafer/Ponitor

.on('response', function(response) {
  response.setEncoding = 'utf8';
  response.on('data', function(chunk) {
    body.push(chunk);
    size += chunk.length;
  });
})
.on('error', function(err) {
  reject(err);
})
.on('end', function() {
  const bff = Buffer.concat(body, size);
  const text = iconv.decode(bff, 'GBK');
request(npm)Responseon

Most used request functions

  • request
  • Response.statusCode
  • RequestAPI.post
  • RequestAPI.get
  • Request.pipe
  • rp,
  • Request.on,
  • Response.headers,
  • RequestAPI.defaults,
  • RequestAPI.put,
  • RequestAPI.jar,
  • Response.statusMessage,
  • RequestAPI.head,
  • Response.on,
  • RequestAPI.cookie,
  • RequestAPI.delete,
  • Response.pipe,
  • RequestAPI.del,
  • requestRetry

Popular in JavaScript

  • mime-types
    The ultimate javascript content-type utility.
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • async
    Higher-order functions and common patterns for asynchronous code
  • request
    Simplified HTTP request client.
  • debug
    small debugging utility
  • path
  • axios
    Promise based HTTP client for the browser and node.js
  • aws-sdk
    AWS SDK for JavaScript
  • winston
    A logger for just about everything.
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now