Skip to content

Instantly share code, notes, and snippets.

@vinaymavi
Created January 13, 2020 17:39
Show Gist options
  • Save vinaymavi/53fa63889e4bfdb4b173505accd6978e to your computer and use it in GitHub Desktop.
Save vinaymavi/53fa63889e4bfdb4b173505accd6978e to your computer and use it in GitHub Desktop.
const http = require('http');
exports.handler = async (event) => {
// TODO implement
const response = await getURL();
return response;
};
function getURL(){
console.log("GET URL");
return new Promise((resolve,reject)=>{
http.get({
hostname: 'ip-10-0-1-114.ap-south-1.compute.internal',
port: 80,
path: '/',
agent: false // Create a new agent just for this one request
}, (res) => {
res.setEncoding('utf8');
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => {
console.log(body);
const response = {
statusCode: 200,
body: body
};
resolve(response);
});
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment