Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 964 Bytes

File metadata and controls

49 lines (38 loc) · 964 Bytes

Calling Pattern

All calls to Microsoft Graph are chained together starting with .api(), then chain query parameters and end with an action.

Path supports the following formats

  • me
  • /me
  • https://graph.microsoft.com/v1.0/me
  • https://graph.microsoft.com/beta/me
  • me/events?$filter=startswith(subject, "Adventure")

Promise based calling

Getting user details with async/await,

try {
    let res = await client.api("/me").get();
    console.log(res);
} catch (error) {
    throw error;
}

Getting user details with then/catch,

client
    .api('/me')
    .get()
    .then((res) => {
        console.log(res);
    }).catch((err) => {
        console.log(err);
    });

Callback based calling

Getting user details by passing callback,

client
    .api('/me')
    .get((err, res, rawResponse) => {
        console.log(res);
    });