When using `cloud.API`, should I `require` my modu...
# general
t
When using
cloud.API
, should I
require
my modules inside the
get
function itself? I tried to use
request
imported on top of the files and it failed with a warning not to close on requires... So I do
Copy code
endpoint.get("/", (req, res) => {
    const request = require('request');
    request(url, ...
w
Yes - that will work, and is generally recommended currently. This ensures that you will get exactly this
require
at runtime. We are discussing in https://github.com/pulumi/pulumi/issues/1588#issuecomment-401968174 an approach which would allow capture of top-level imports to be interpreted as a top-level
require
at runtime - feel free to add in there as well.
👍 1