-
Objective: I am currently adding a button to the control.vue of the frontend-2 that I would like to make an API request to an internal API endpoint to add some custom functionalities and I am currently a bit stumpt on what the best way to get the modelUrl and Authentication token required for the SpeckleLoader to download the model.
-
Current Appraoch: I am unsure if my approach is the best way to proceed. Currently, when the button is pressed, I’m getting the following values for the authentication token and URL. For the model URL, I simply grab the current weburl since this executing in the model view page.
These values work for making the api call and being able to get responses I’m expecting during local build tests but I’m not sure duirng deployment if this appraoch will scale would love to get input on best practice in achieving this.
import { useAuthCookie } from '../../../lib/auth/composables/auth'
const authToken = useAuthCookie()
const modelUrl = window.location.href;
Essentially, this button is added to the side panel of controls. I realized this isn’t the correct picture showing the button, but it’s added after the side panel, and the script above is triggered to get those values every time the user presses that button.