UI Kit

Calling Functions

Once you have a DroneDeploy Function defined and deployed, you might want to call the Function from your App's UI. We have built App APIs to make this very easy.

First, you want to get the URL of the Function. You can do this by passing in the Function's name into the following API.


Second, you will want to get a scoped JWT token. This provides authentication and authorization when calling your Function and also provides your Function with a token to make further calls to our APIs. You will set the returned JWT as the Bearer Token for your request.


Finally, here's an example of what your UI app code might look like when calling a function:

const dronedeploy = new DroneDeploy({version: 1});
const FUNCTION_NAME = "ifttt-webhook";

 * Generic function for calling out to Function
async function callFunction() {
  const api = await dronedeploy;

  // Grabs the URL of the function to call by name of function
  const functionUrl = await api.Functions.getUrl(FUNCTION_NAME);

  // Get a token to ensure auth when calling your function
  const token = await api.Authorization.getScopedToken();
  // Additional headers, such as "Content-Type", may be necessary
  const options = {
    method: "POST",
    body: JSON.stringify({data: "hello world"}),
    headers: {
        Authorization: `Bearer ${token}`
  return fetch(functionUrl, options);

You can see how this all works in our sample app.

Last updated