Autodesk Forge - Extension button to get data from external SQL database

Viewed 140

I am trying to connect my Forge app to a sql database, but I have no idea how to do that. I am new to forge and web development, so I don't know how to look for the best approach to solve this. I found a code that does exactly what I want, that is getting the data from a specific table of my database, but I'm not able to put this code inside my forge app, mainly because it uses a require() function and I can't put it inside my extension button. By the way, I'm trying to make a button in my extension where I click, it access my database and get data from it. Would be really nice if someone could help me with this silly doubt that probably already has a solution in the internet and I'm not able to find it. Sorry in advance if it's too obvious.

1 Answers

This problem is more related to web development than Forge. Your app should be made of 2 parts : the frontend (html/css/js) and a backend (probably nodejs as you tagged it). Your frontend should not access the database directly. This is the job of your backend.

In your backend, add a library to access your database such as Sequelize (if you are working with NodeJS). Then you will do a request from your frontend to your backend to get the data from the database. You probably have something working like that for your Forge Access Token, depending on what you use to start your development.

Related