Data API Integration
We can use the Execute FileMaker Data API
script step to harness the power of the @proofkit/fmdapi library in our webviewer integration.
- ✅ Use the same code and functions as in a browsed-based app
- including typegen for a nice auto-complete experience and runtime validation for protection if field names are changed.
- ✅ No authentication required (it runs in the process of the logged in user)
- ✅ Works in offline FileMaker apps
- ✅ Works even if the Data API is disabled on the server
Setup
If you used the ProofKit CLI to create your project, these steps are already done for you.
Install both packages
npm install @proofkit/fmdapi @proofkit/webviewer
FileMaker Script Installation
Copy the ExecuteDataAPI
and SendCallback
scripts from the demo file to your own FileMaker solution.
Initialize the DataAPI client
For more details about this step, see the @proofkit/fmdapi documentation.
If you're using using typegen, modify your fmschema.config.mjs
file to include the script name that calls the Execute FileMaker Data API
script step
export const config = {
// ...other config
webviewerScriptName: "ExecuteDataApi",
};
Then simply run the typegen command to generate the client.
Usage
Now you can use the DataAPI client just as you would in a browsed-based app!
import { UsersClient } from "./schema/client";
const users = await UsersClient.findOne({ query: { id: "===1234" } });
For examples of all methods, see the @proofkit/fmdapi documentation.