Resolver definitions not being recognized by invokes

FaaS:

import Resolver from '@forge/resolver';

const resolver = new Resolver();

resolver.define('getText', (req) => {
  // console.log(req);
  return 'Hello World!';
});

resolver.define('getX', (req) => {
  return 'X';
});

export const handler = resolver.getDefinitions();

App.js:

import React, { useEffect, useState } from "react";
import { invoke } from "@forge/bridge";

function App() {
  const [data, setData] = useState(null);

  useEffect(() => {
    invoke('getX', { example: "my-invoke-variable" }).then(setData);
  }, []);

  return <div>{data ? data : "Loading..."}</div>;
}

export default App;

It is meant to invoke the getX function, however, the invoke is still calling the ‘getText’ resolver definition. If I removed the getText definition and re-deploy, it hangs on Loading…

It is likely something I am overlooking but I cannot find similar problems in the forum search or in Custom UI docs.

Hi @CoreyMosley , since this is a Custom UI application, you will need to build your front-end code before re-deploying for the new changes to take effect.

> cd static/hello-world

> npm run build

> cd ../..

> forge deploy

Let us know if this doesn’t work.

1 Like

That absolutely worked. Thank you. I used this pattern for the initial deployment but I did not realize that it had to be build every time prior to deployment.

Thanks!