Microsoft graph : UnhandledPromiseRejectionWarning: PolyFillNotAvailable: Library cannot function without fetch. So, please provide polyfill for it

Total
4
Shares

Microsoft graph throws the below exception when initializing the client using the access token

enter image description here

the access token was generated just before initializing the client & also the same token works in post-man

what is that I’m doing wrong?

code 👇👇

let graphClient = graph.Client.init({
        // Use the provided access token to authenticate
        // requests
        authProvider: (done) => {
            done(null, accessToken);
        }
    });

Post-man response 👇👇

enter image description here


Solution

Quoting the install guide:

import @microsoft/microsoft-graph-client into your module and also you will need polyfills for fetch like isomorphic-fetch.

Here is what you need to do.

npm install isomorphic-fetch
import "isomorphic-fetch"; OR require('isomorphic-fetch');
Leave a Reply

Your email address will not be published. Required fields are marked *