none
Trying to understand graph api javascript example? RRS feed

  • Question

  • I have the code below , an example from the graph API website


    const options = {
    	authProvider,
    };
    
    const client = Client.init(options);
    
    let res = await client.api('/me/events')
    	.select('subject,body,bodyPreview,organizer,attendees,start,end,location')
    	.get();

    I tried to just surroundes the JS with a script tag trying to get this to work , but it doesnt work so here are my questions:

    1-how do I authenticate and pass Username and Password to the API?

    2-I get these errors

    Uncaught SyntaxError: await is only valid in async function favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)


    this is the cal.html file ...any ideas?

    <html>
    <head>
    <script>
    const options = {
    	authProvider,
    };
    
    const client = Client.init(options);
    
    let res = await client.api('/me/calendarview?startdatetime=2020-07-26T21:13:18.628Z&enddatetime=2020-08-02T21:13:18.628Z')
    	.get();
    </script>
    </head>
    <body>
    </body>
    </html>

    Sunday, August 23, 2020 7:15 PM