How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • // Before running the sample:
    // - Enable the API at:
    //   https://console.developers.google.com/apis/api/gmail.googleapis.com
    // - Login into gcloud by running:
    //   `$ gcloud auth application-default login`
    // - Install the npm module by running:
    //   `$ npm install googleapis`
    
    const {google} = require('googleapis');
    const gmail = google.gmail('v1');
    
    async function main() {
      const auth = new google.auth.GoogleAuth({
        // Scopes can be specified either as an array or as a single, space-delimited string.
        scopes: [
          'https://mail.google.com/',
          'https://www.googleapis.com/auth/gmail.addons.current.message.action',
          'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',
          'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
          'https://www.googleapis.com/auth/gmail.metadata',
          'https://www.googleapis.com/auth/gmail.modify',
          'https://www.googleapis.com/auth/gmail.readonly',
        ],
      });
    
      // Acquire an auth client, and bind it to all future calls
      const authClient = await auth.getClient();
      google.options({auth: authClient});
    
      // Do the magic
      const res = await gmail.users.messages.get({
        // The format to return the message in.
        format: 'placeholder-value',
        // The ID of the message to retrieve. This ID is usually retrieved using `messages.list`. The ID is also contained in the result when a message is inserted (`messages.insert`) or imported (`messages.import`).
        id: 'placeholder-value',
        // When given and format is `METADATA`, only include headers specified.
        metadataHeaders: 'placeholder-value',
        // The user's email address. The special value `me` can be used to indicate the authenticated user.
        userId: 'placeholder-value',
      });
      console.log(res.data);
    
      // Example response
      // {
      //   "historyId": "my_historyId",
      //   "id": "my_id",
      //   "internalDate": "my_internalDate",
      //   "labelIds": [],
      //   "payload": {},
      //   "raw": "my_raw",
      //   "sizeEstimate": 0,
      //   "snippet": "my_snippet",
      //   "threadId": "my_threadId"
      // }
    }
    
    main().catch(e => {
      console.error(e);
      throw e;
    });
    
    Docs
  • // Before running the sample:
    // - Enable the API at:
    //   https://console.developers.google.com/apis/api/gmail.googleapis.com
    // - Login into gcloud by running:
    //   `$ gcloud auth application-default login`
    // - Install the npm module by running:
    //   `$ npm install googleapis`
    
    const {google} = require('googleapis');
    const gmail = google.gmail('v1');
    
    async function main() {
      const auth = new google.auth.GoogleAuth({
        // Scopes can be specified either as an array or as a single, space-delimited string.
        scopes: [
          'https://mail.google.com/',
          'https://www.googleapis.com/auth/gmail.addons.current.message.action',
          'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',
          'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
          'https://www.googleapis.com/auth/gmail.metadata',
          'https://www.googleapis.com/auth/gmail.modify',
          'https://www.googleapis.com/auth/gmail.readonly',
        ],
      });
    
      // Acquire an auth client, and bind it to all future calls
      const authClient = await auth.getClient();
      google.options({auth: authClient});
    
      // Do the magic
      const res = await gmail.users.threads.get({
        // The format to return the messages in.
        format: 'placeholder-value',
        // The ID of the thread to retrieve.
        id: 'placeholder-value',
        // When given and format is METADATA, only include headers specified.
        metadataHeaders: 'placeholder-value',
        // The user's email address. The special value `me` can be used to indicate the authenticated user.
        userId: 'placeholder-value',
      });
      console.log(res.data);
    
      // Example response
      // {
      //   "historyId": "my_historyId",
      //   "id": "my_id",
      //   "messages": [],
      //   "snippet": "my_snippet"
      // }
    }
    
    main().catch(e => {
      console.error(e);
      throw e;
    });
    
    Docs
  • // Before running the sample:
    // - Enable the API at:
    //   https://console.developers.google.com/apis/api/gmail.googleapis.com
    // - Login into gcloud by running:
    //   `$ gcloud auth application-default login`
    // - Install the npm module by running:
    //   `$ npm install googleapis`
    
    const {google} = require('googleapis');
    const gmail = google.gmail('v1');
    
    async function main() {
      const auth = new google.auth.GoogleAuth({
        // Scopes can be specified either as an array or as a single, space-delimited string.
        scopes: [
          'https://mail.google.com/',
          'https://www.googleapis.com/auth/gmail.labels',
          'https://www.googleapis.com/auth/gmail.metadata',
          'https://www.googleapis.com/auth/gmail.modify',
          'https://www.googleapis.com/auth/gmail.readonly',
        ],
      });
    
      // Acquire an auth client, and bind it to all future calls
      const authClient = await auth.getClient();
      google.options({auth: authClient});
    
      // Do the magic
      const res = await gmail.users.labels.get({
        // The ID of the label to retrieve.
        id: 'placeholder-value',
        // The user's email address. The special value `me` can be used to indicate the authenticated user.
        userId: 'placeholder-value',
      });
      console.log(res.data);
    
      // Example response
      // {
      //   "color": {},
      //   "id": "my_id",
      //   "labelListVisibility": "my_labelListVisibility",
      //   "messageListVisibility": "my_messageListVisibility",
      //   "messagesTotal": 0,
      //   "messagesUnread": 0,
      //   "name": "my_name",
      //   "threadsTotal": 0,
      //   "threadsUnread": 0,
      //   "type": "my_type"
      // }
    }
    
    main().catch(e => {
      console.error(e);
      throw e;
    });
    
    Docs
  • // Before running the sample:
    // - Enable the API at:
    //   https://console.developers.google.com/apis/api/gmail.googleapis.com
    // - Login into gcloud by running:
    //   `$ gcloud auth application-default login`
    // - Install the npm module by running:
    //   `$ npm install googleapis`
    
    const {google} = require('googleapis');
    const gmail = google.gmail('v1');
    
    async function main() {
      const auth = new google.auth.GoogleAuth({
        // Scopes can be specified either as an array or as a single, space-delimited string.
        scopes: ['https://mail.google.com/'],
      });
    
      // Acquire an auth client, and bind it to all future calls
      const authClient = await auth.getClient();
      google.options({auth: authClient});
    
      // Do the magic
      const res = await gmail.users.messages.delete({
        // The ID of the message to delete.
        id: 'placeholder-value',
        // The user's email address. The special value `me` can be used to indicate the authenticated user.
        userId: 'placeholder-value',
      });
      console.log(res.data);
    }
    
    main().catch(e => {
      console.error(e);
      throw e;
    });
    
    Docs
  • // Before running the sample:
    // - Enable the API at:
    //   https://console.developers.google.com/apis/api/gmail.googleapis.com
    // - Login into gcloud by running:
    //   `$ gcloud auth application-default login`
    // - Install the npm module by running:
    //   `$ npm install googleapis`
    
    const {google} = require('googleapis');
    const gmail = google.gmail('v1');
    
    async function main() {
      const auth = new google.auth.GoogleAuth({
        // Scopes can be specified either as an array or as a single, space-delimited string.
        scopes: [
          'https://mail.google.com/',
          'https://www.googleapis.com/auth/gmail.modify',
        ],
      });
    
      // Acquire an auth client, and bind it to all future calls
      const authClient = await auth.getClient();
      google.options({auth: authClient});
    
      // Do the magic
      const res = await gmail.users.messages.batchModify({
        // The user's email address. The special value `me` can be used to indicate the authenticated user.
        userId: 'placeholder-value',
    
        // Request body metadata
        requestBody: {
          // request body parameters
          // {
          //   "addLabelIds": [],
          //   "ids": [],
          //   "removeLabelIds": []
          // }
        },
      });
      console.log(res.data);
    }
    
    main().catch(e => {
      console.error(e);
      throw e;
    });
    
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples