Created
January 13, 2020 17:39
-
-
Save vinaymavi/53fa63889e4bfdb4b173505accd6978e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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