No observers registered for this request.

Hesham Khedr 0 Reputation points
2025-01-26T11:45:11.16+00:00

I'm using pnpjs/graph library to select users

Error: No observers registered for this request. (https://pnp.github.io/pnpjs/queryable/queryable#no-observers-registered-for-this-request).

import { SPFI, spfi, SPFx, DefaultInit, DefaultHeaders } from '@pnp/sp';
import { BrowserFetchWithRetry, DefaultParse } from "@pnp/queryable";
import "@pnp/sp/webs";




 protected async onInit(): Promise<void> {

    
   const  _sp = spfi().using(DefaultInit(), DefaultHeaders(), BrowserFetchWithRetry(), DefaultParse(), SPFx(this.context));
    
   
    // async all users to employee table
    
const graph: GraphFI = graphfi();
const users = await graph.users.top(100)();
    

    return super.onInit();
  }
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,015 questions
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,276 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 28,126 Reputation points Microsoft Vendor
    2025-01-27T07:56:15.4033333+00:00

    Hi @Hesham Khedr ,

    The error message you're seeing, "No observers registered for this request," typically occurs when a pnpjs query is executed but no response handlers or observers are set up to handle the result.

    1.Ensure that you are using the correct version of the pnpjs library. Sometimes, version mismatches can cause unexpected errors. Make sure you are using the latest version of the library.

    2.Imports: Ensure graphfi() is imported from @pnp/graph to initialize the Graph client.

    import { graphfi, GraphFI } from "@pnp/graph";
    

    3.Logging: You can log the users to the console to inspect the result.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

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.