I’ve hit a wall trying to use api.asApp() inside a Forge resolver function. I’ve spent a lot of time on this and am out of things to check. I am hoping someone can help or confirm what I am seeing.
I’m building a Forge Custom UI app to prompt for a Jira board ID and in the back end use api.asApp()
in a resolver to call /rest/agile/1.0/board/{boardId}/configuration
storage.get(...)
andstorage.set(...)
work perfectly- app runs on
nodejs22.14.0
- tried on two different machines
However I get api
is undefined
inside the resolver: TypeError: Cannot read properties of undefined (reading ‘asApp’)
mainifest
app:
runtime:
name: nodejs22.x
function:
- key: resolver
handler: index.handler
src/index.js
(resolver)
import Resolver from '@forge/resolver';
import { storage, api } from '@forge/api';
const resolver = new Resolver();
resolver.define('setBoardConfig', async ({ payload }) => {
console.log('🧪 typeof api:', typeof api);
console.log('🧪 api keys:', Object.keys(api || {}));
const response = await api.asApp().requestJira(`/rest/agile/1.0/board/${payload.boardId}/configuration`);
const data = await response.json();
await storage.set(`board-config-${payload.projectKey}`, data);
return { success: true };
});