Tabnine Logo For Javascript
http
Code IndexAdd Tabnine to your IDE (free)

How to use http

Best JavaScript code snippets using http(Showing top 15 results out of 12,951)

origin: yagop/node-telegram-bot-api

function startStaticServer(port) {
 const fileServer = new statics.Server(`${__dirname}/data`);
 http.Server((req, res) => {
  req.addListener('end', () => {
   fileServer.serve(req, res);
  }).resume();
 }).listen(port);
}
origin: parse-community/parse-server

function get(options, noJSON = false) {
 return new Promise((resolve, reject) => {
  https
   .get(options, makeCallback(resolve, reject, noJSON))
   .on('error', reject);
 });
}
origin: BretFisher/node-docker-good-defaults

http.request(options, (res) => {
 console.info('STATUS: ' + res.statusCode);
 process.exitCode = (res.statusCode === 200) ? 0 : 1;
 process.exit();
})
origin: eggjs/egg

app.ready().then(() => {
 console.log('app(%s) ready', app.config.baseDir);

 const server = http.createServer(app.callback());
 // emit server event just like egg-cluster does
 // https://github.com/eggjs/egg-cluster/blob/master/lib/app_worker.js#L52
 app.emit('server', server);

 server.listen(7001, () => {
  console.log('Server started at 7001');
 });
});
origin: nodejs/nodejs.org

// Initializes the server and mounts it in the generated build directory.
http.createServer((req, res) => {
 // If we are accessing the root, it should be redirected to the default language,
 // We shouldn't get a 404 page.

 if (req.url === '/') {
  req.url = `/${mainLocale}`
 }
 mount(req, res)
}).listen(port, () => {
 console.log(`\x1B[32mServer running at http://localhost:${port}/${mainLocale}/\x1B[39m`)
})
origin: parse-community/parse-server

https.request(request, function (res) {
   var data = '';
   res.on('data', function (chunk) {
    data += chunk;
   });
   res.on('end', function () {
    data = JSON.parse(data);
    resolve(data);
   });
  }).on('error', function () {
   reject('Failed to make an OAuth request');
  })
origin: GoogleCloudPlatform/nodejs-docs-samples

describe('gae_flex_redislabs_memcache', () => {
 it('should be listening', async () => {
  const server = require('../app.js');
  const isOpen = await waitPort({port: PORT});
  expect(isOpen).to.be.true;
  server.close();
 });
});
origin: rchipka/node-osmosis

http.createServer(function (req, res) {
  var url = URL.parse(req.url);

  res.writeHead(200, { 'Content-Type': 'text/html' });
  res.end(fs.readFileSync(__dirname + url.pathname));
})
origin: clinicjs/node-clinic

listen (callback) {
  const self = this
  this.server.listen(0, '127.0.0.1', function () {
   self.uploadUrl = `http://127.0.0.1:${self.server.address().port}`
   callback()
  })
 }
origin: laurent22/joplin

https.get(url, function(response) {
      if (response.statusCode !== 200) reject(new Error(`HTTP error ${response.statusCode}`));
      response.pipe(file);
      file.on('finish', function() {
        // file.close();
        resolve();
      });
    }).on('error', (error) => {
      reject(error);
    });
origin: parse-community/parse-server

function request(options, postData) {
 return new Promise((resolve, reject) => {
  const req = https.request(options, makeCallback(resolve, reject));
  req.on('error', reject);
  req.write(postData);
  req.end();
 });
}
origin: parse-community/parse-server

const downloadFileFromURI = uri => {
 return new Promise((res, rej) => {
  http.get(uri, response => {
   response.setDefaultEncoding('base64');
   let body = `data:${response.headers['content-type']};base64,`;
   response.on('data', data => body += data);
   response.on('end', () => res(body));
  }).on('error', e => {
   rej(`Error downloading file from ${uri}: ${e.message}`);
  });
 });
}
origin: lewis617/react-redux-tutorial

server.listen(process.env.PORT || 3000, function onListen() {
  var address = server.address();
  console.log('Listening on: %j', address);
  console.log(' -> that probably means: http://localhost:%d', address.port);
 });
origin: parse-community/parse-server

function get(options, noJSON = false) {
 return new Promise((resolve, reject) => {
  https.get(options, makeCallback(resolve, reject, noJSON)).on('error', reject);
 });
}
origin: parse-community/parse-server

function request(options, postData) {
 return new Promise((resolve, reject) => {
  const req = https.request(options, makeCallback(resolve, reject));
  req.on('error', reject);
  req.write(postData);
  req.end();
 });
}
http

Most used http functions

  • Server.listen
  • createServer
  • Server.address
  • IncomingMessage.on
  • ServerResponse.end
  • IncomingMessage.url,
  • ServerResponse.writeHead,
  • ClientRequest.end,
  • IncomingMessage.statusCode,
  • Server.close,
  • Server.on,
  • IncomingMessage.headers,
  • request,
  • get,
  • IncomingMessage.setEncoding,
  • ServerResponse.write,
  • ClientRequest.write,
  • IncomingMessage.pipe,
  • IncomingMessage.method

Popular in JavaScript

  • lodash
    Lodash modular utilities.
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • mocha
    simple, flexible, fun test framework
  • mongodb
    The official MongoDB driver for Node.js
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • crypto
  • commander
    the complete solution for node.js command-line programs
  • Top 12 Jupyter Notebook extensions
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