Skip to content

Instantly share code, notes, and snippets.

@yingmu52
Last active February 27, 2018 06:14
Show Gist options
  • Save yingmu52/f4f711c7d325fa7e2ac2ab7b4feb780e to your computer and use it in GitHub Desktop.
Save yingmu52/f4f711c7d325fa7e2ac2ab7b4feb780e to your computer and use it in GitHub Desktop.
http node
const https = require('https');
https.get('https://jsonplaceholder.typicode.com/posts/1', (resp) => {
  let data = '';
  resp.on('data', (chunk) => {    
data += chunk;
});
  resp.on('end', () => {
console.log(data)
  });
}).on("error", (err) => {
  console.log("Error: " + err.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment