(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);
  };
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,583 questions
0 comments No comments
{count} votes

Your answer

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