A way to fetch Microsoft Graph locations with PnPJs

391 Views Asked by At

As stated above in the title I am currently facing issues fetching graph places with PnPJs, using the @pnp/graph graphfi factory interface in SPFx.

I am currently able to fetch data from my events via graphfi as can be seen below:

React.useEffect(() => {
    graph = graphfi().using(SPFx(props.context));
    getSpecificCalendar();
}, []);

const getSpecificCalendar = async () => {
    await graph.me.events().then((e) => setCalendarEvent(e));
} 

I have tried to get the places property from the graph object but to no avail. The only properties present are me and users but no option for places. Esentially what I want to do is to graph.places. The conclusion I have come to is that @pnp/graph does not have any methods to get room data. Any ideas other than what I have tried above would be extremely helpful.

1

There are 1 best solutions below

2
Nikolay On

It looks like pnpjs does not have the /places endpoint implemented (yet). You could try using the built-in SPFx graph client for now. Something like:

const client = await props.context.msGraphClientFactory.getClient('3')
const response = await client.api('/places/......').get();

Alternatively, you could implement the /places endpoint yourself and submit a pull request for pnpjs :)