I have a module that prompts the user with questions step by step and I want to save their answers in a hubdb table. Am I able to access the CMS API through a custom module using a javascript curl request? Or is their a better way to do it?
Hi, @AMastoris
Thanks for your question.
I’d recommend looking into utilizing Serverless Functions if you have access. Or researching setting up some form of middleware. My main concerns with doing this client-side are:
- Security — you risk exposing your API or Private App keys by making calls client-side (from your module in this case) — Include serverless functions in projects (BETA) and Serverless functions
- CORS restrictions — HubSpot may block your cross-origin requests
- Rate limiting and performance — if multiple users are interacting with your application simultaneously, you may hit rate limits. Managing this server-side allows you more flexibility and control over how the calls are sent
Have fun building! — Jaycee