DEV Community

Http Request with AWS Lambda, Node.js 8.10, and Standard http library

Scott Lepper on June 10, 2018

In my previous article I showed an approach to extend a "traditional" (monolithic architecture) app using AWS Lambda: https://dev.to/scottlepp/ext...
Collapse
 
jsiesquen profile image
Juan Siesquen • Edited

Hi Scott,

I'm using the request-promise library but when try insert within exports.handler this aren't work... this is part of code, your support please, I'm novice yet:

How can implement this requests into lambda function?.... in my local test this work!

Or maybe should reemplace the requet-promise reference per a simple "http.request"?? Opinions please?

Thanks very much for advance.....

Regards

Collapse
 
jsiesquen profile image
Juan Siesquen • Edited

Hi Guys,

Finally, as I not know much about "request-promise" module, use "request-promise-native" instead. I have this model...

You already have an array with the results and the code looks synchronous.

I hope that is model can use for others verbs like post and patch. I'm in testing yet. Will I do well?

Collapse
 
adamshechter9 profile image
Adam Shechter

Awesome!
thank you, this is exactly what I needed.

Collapse
 
fcpauldiaz profile image
Pablo Díaz

Nice and clean!

Collapse
 
nicolasmorinpomerleau profile image
nicolasmorinpomerleau • Edited

In case of Lambda project, what urls we put in host and path parameters ?

Collapse
 
scottlepp profile image
Scott Lepper

In this case I was running Voyager Search on an ec2 instance. The host was the ec2 instance and the path was to a REST call that Voyager Search supports, but you could take this approach with any REST provider.

Collapse
 
liambarnettit profile image
Liam Barnett

Useful post - thanks!

Collapse
 
lucallero profile image
Luciano Callero

Helpful indeed, thanks!