@forge/api, apiClient is not a function error

I am using import { storage } from “@forge/api”;

useEffect(() => {
storage.set(“test”, “someValue”).then(
storage.get(“test”).then((value) => {
console.log("value: ", value);
})
);
}, );

Getting error apiClient is not a function.
can anyone tell me its happening?

Just as a sanity check are you making a Custom UI app or a UI kit app?

Also where is that particular code? Is it in the static/ folder or src/?

Its in the static folder. like this static/hello-world/src/…

Just in case anyone doesn’t know
static/ is for frontend files that will be served to the user to run and render.
src contains the script that will be run in your Forge apps backend.

@forge/api is a package that only works in the backend.

2 Likes