Forge/api Cannot read properties of undefined (reading 'fetch')

Edit: added source of error and updated asUser() call. Same result.
Trying to get user data, can’t get past this error.
I’m using a resolver as described in the docs.
In my forge app:

import Resolver from '@forge/resolver';
import api, { route } from "@forge/api";

const resolver = new Resolver();

resolver.define('getUser', async () => {
  const jiraResponse = await api.asUser().requestJira(route`/rest/api/3/myself`);
  return await jiraResponse.json();

In my App.js:

    const [ user, setUser ] = useState(null);
    useEffect(() => {
        invoke('getUser', {example: 'my-invoke-variable'}).then(setUser);
    }, []);

Console error:

index.js:22 Uncaught TypeError: Cannot read properties of undefined (reading 'fetch')
    at Object.t.wrapFetchApiMethods (index.js:22:53)
    at Object.1030 (index.js:19:24)
    at n (bootstrap:19:22)
    at slicedToArray.js:6:103
    at index.js:12:29
    at index.js:12:29


Error line:

I’ve loaded and reloaded dependencies, tried different package versions, rebuilt node_modules numerous times. No dice.

Forge package:

  "name": "cnp-time-app",
  "version": "0.1.2",
  "main": "index.js",
  "license": "MIT",
  "private": true,
  "devDependencies": {
    "eslint": "^6.0",
    "eslint-plugin-react-hooks": "^2.0"
  "dependencies": {
    "@forge/api": "2.1",
    "@forge/bridge": "^2.1.3",
    "@forge/resolver": "^1.3.5"

App package:

  "name": "app",
  "version": "0.1.1",
  "private": true,
  "homepage": ".",
  "dependencies": {
    "@atlaskit/css-reset": "^6.0.1",
    "@forge/api": "^2.1",
    "@forge/bridge": "^2.1.3",
    "@forge/ui": "^0.16.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "^5.0.0",
    "webpack": "4.31"
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "eject": "react-scripts eject"
  "browserslist": {
    "production": [
      "not dead",
      "not op_mini all"
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"

I believe I have the correct manifest permissions as well:

    - read:jira-user
    - read:jira-work

Hi @JimConte, thank you for reaching out.
I assume your resolver is declared in manifest as an example in docs:
It looks like the problem with calling jira API in your resolver function logic itself.

I’m not sure what exactly can be a cause of your error. I did similar exercise myself and it works as expected. Below few tips that may help:

  1. I believe you don’t need @forge dependencies in your App package - only @forge/bridge is required.
  2. Build your static part first static/<your_dir> (npm install, npm run build`).
  3. Please make sure you run npm install in your root directory before you run forge deploy.
  4. Please try reinstalling your app (forge uninstall and then forge install).

If it won’t help we will try to investigate it further. You can debug your app with forge tunnel - it can provide additional error messages that could be useful.

Thank you!
It may have been my switching versions to try different approaches that was causing my problems.
I deleted all of my node_modules, and completely reinstalled all. I also reinstalled docker desktop, and was able to get forge tunnel working, which provided a little more insight.
It is all working at this point, thanks for the sanity check!

1 Like