Hello, I am trying to translate the following into hubl, so I can use it in a custom module. What this code does is it gets the current user's ID to extract data about them. Ultimately I am trying to figure out what Lists the current user is on.
So HUBL is a subset of Jinja, which is a templating language. By defenition templating languages do not have the ability to make http request. In your case you've got a few options:
if the user is cookied via form you can use the HUBL {{ contact }} variable to access basic information about the contact like email, name, and id.
you can use the ID from the above with JS to make an API call to a serverless function or external server to retrieve more data from the contact record
I would also nudge you to check out the available HUBL functions.
So HUBL is a subset of Jinja, which is a templating language. By defenition templating languages do not have the ability to make http request. In your case you've got a few options:
if the user is cookied via form you can use the HUBL {{ contact }} variable to access basic information about the contact like email, name, and id.
you can use the ID from the above with JS to make an API call to a serverless function or external server to retrieve more data from the contact record
I would also nudge you to check out the available HUBL functions.
This is a great answer. My only follow up question is: wouldn't I need my private app key to access data with an API call - in which case using js would make it available on the frontend? That seems like a huge security risk.. or am I missing something?
Yes you would, and this is where the serverless function/lambda comes into play. By running that request in a secure environment that has access to your auth you avoid security issues.
So your flow would be something like:
page loads
module JS makes request to serverless function
serverless function makes authentiated request to hubspot and return the needed data