0

I've created a javascript script that will get information from this api. I'm trying to set this up inside of a google cloud function. I understand how you "require" or "import" a reference normally inside of a google cloud function, and even that you can make reference to a local file. When i downloaded the api.js from the source and try to reference it, i get "bomgarState is undefined" where bomgarState is the reference that i need. I understand that it is looking for a json when an api is being defined but i need to use the api.js. I know that this code can work,when you run this in collaboration with an html that sources said api, i have no problems. I have tried many different solutions such as "require(./api.js)", getting from url, and much more but am unsure if this is something that is supported at this point.

TLDR: can't make reference or source a javascript api inside of google cloud functions, had been sourcing using html, now that we moved to google cloud functions can't figure out how to make reference.

1 Answers1

0

For you to import dependencies and libraries to your Cloud Functions, there are some available options that you can take with JavaScript, but only while using Node.js - without Node it's not possible.

For example, as the documentation Specifying dependencies in Node.js indicates:

A function is allowed to use external Node.js modules as well as local data. Dependencies in Node.js are managed with npm and expressed in a metadata file called package.json.

So, you can use with Node.js the npm to import your dependencies to your Cloud Functions.

Other options are indicated in the following posts from the Community - that I would recommend you to take a look at it - one, for example, would be using the 'gcloud' command to deploy your function. This way, it would upload and deploy with all files from your directory.

I hope these articles help you, since they indicate the only available options, unfortunately, to upload dependencies on your Cloud Functions.