Share via

(Graph API Issue in SPFx Application: Error when not connected to VPN). SPFx Application is integrated with graph Api to do crud operations, when end user is connected with vpn its works but without vpn its started throwing error ,

Kovuri, Amar Nath 0 Reputation points
2025-04-30T09:44:01.3133333+00:00

SPFx Application is integrated with graph Api to do crud operations, when end user is connected with vpn its works but without vpn its started throwing the below error {"statusCode":-1,"code":"TypeError","requestId":null,"date":"2025-04-29T13:48:36.433Z","body":"TypeError: Failed to fetch"}.

sharing the piece of code which we are using to get the data with msgraphclient .

it would be helpful if we can get any solution or any other alternate ways to do the call.

import { MSGraphClientFactory, MSGraphClientV3 } from "@microsoft/sp-http";

export class GraphListService {
  private static _graphClient: MSGraphClientV3;

  public static async Init(msGraphClientFactory: MSGraphClientFactory): Promise<void> {
    this._graphClient = await msGraphClientFactory.getClient('3');
  }


 public static getListItemsByFilter = async (
    listId: string,
    selectColumns: string,
    filter: string,
    orderby: string = "",
    service
  ): Promise<any> => {
    try {
      const data = await this._graphClient
        .api(
          `/sites/siteid/lists/${listId}/items?expand=fields(select=${selectColumns})&$filter=${filter}&$orderby=${orderby}`).get();
      console.log(data, 'res in helper')
    } catch (error) {
      return console.log("Error getting items by filter from the list", error);
  };
Microsoft 365 and Office | SharePoint | Development
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.