Met ReferenceError: window is not defined just import requestJira in resolvers/index.js

I just import requestJira in index.js.then I met this problem..it’s working after delete this line.

why is this happening?

Hey @SUDerekR ,

It looks like you’re trying to make an API call to Jira via the forge resolver (ie the backend). However the @forge/bridge package will only work via the frontend.

To make API calls via the resolver, you should use the requestJira command from within the @forge/api package

So, in your example - you should use the following imports :

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

Then, to make the api call, you’ll need to use a slightly different format to what is used by requestJira in @forge/bridge:

const result = await api
    .asApp()
    .requestJira(
      path[, options]
    );
const status = result.status;

IMPORTANT you will need to run the command npm install @forge/api after making the changes in your ‘resolvers/index.js’ to install the package in your app.

you can find the docs at https://developer.atlassian.com/platform/forge/apis-reference/fetch-api-product.requestjira/

If this answered your question, please mark it as the solution! If you’re still stuck please let me know below.

Cheers
Mel

1 Like

Got it.Thank you @mpaisley