Skip to main content

invoke

The invoke API allows frontend applications to access backend functions. To use invoke, you first need to define the function using a resolver. Refer to Custom UI Resolver for more details.

You can refer to the demo: invoke

Usage

In the frontend code of Custom UI, import @giteeteam/plugin-sdk

import { invoke } from '@giteeteam/plugin-sdk';

const Demo = () => {
useEffect(() => {
const payload = {
example: 'hello'
}
const result = await invoke("method-key", payload); // payload is the execution parameter
console.log(result) // returned data
},[])

return <div></div>
}

Function Declaration

function invoke(
methodKey: string,
payload?: { [key in number | string]: any }
): Promise<{ [key: string]: any } | void>;

Parameter Explanation

  • methodKey: Corresponds to the methodKey defined in the resolver
  • payload: The data passed to the resolver

Function Definition

Please refer to Custom UI Resolver for more details.