Is there a way to use dynamic endpoints with AWS Lambda?
From what I can tell you need to specific the endpoint in the AWS Lamda Console.
What I need to do is access the URL from database then get the JSON for that URL. The URL will be added contantly by users so I cant possible log in every second to manually add an endpoint.
Considering that I set up my Lambda to Node.JS
I thought that I could just use:
// ----receive function----v
function get_json(url, callback) {
http.get(url, function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
var response = JSON.parse(body);
// call function ----v
callback(response);
});
});
}
// -----------the url---v ------------the callback---v
var mydata = get_json("http://api.openweathermap.org/data/2.5/weather?id=2172797&appid=b1b15e88fa797225412429c1c50c122a", function (resp) {
console.log(resp);
});
but I get this error:
"errorMessage": "http is not defined"
What I need is a way to ue a dynamic URL for the JSON
Can someone help?