Blog ToDos
@raymondcamden
code:
data:privatelast updated:7 months ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 250,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
getToDos
auth
to use OAuth tokens and API keys in code via theauths object
(auths.microsoft_graph_api)
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
}
35

import fetch from 'node-fetch';

const blogList = 'AQMkADAwATMzAGZmAS04MDU4LWQ4ZjctMDACLTAwCgAuAAAD2b-xt4VpMU28CRdh70oBigEAzwpFFkTJnUqSIr7l4olnFgACofznJAAAAA==';
const rootUrl = `https://graph.microsoft.com/v1.0/me/todo/lists/${blogList}/tasks?$filter=status ne 'completed'`;

async function getCompletedToDos(todos = [], url = rootUrl) {

  let result = await fetch(url, {
    headers: {
      'Authorization':`Bearer ${auths.microsoft_graph_api.oauth_access_token}`
    }
  });

  let data = await result.json();

  data.value.forEach(d => {
    todos.push({
      title:d.title,
      created:d.createdDateTime,
      lastModified:d.lastModifiedDateTime, 
      id:d.id,
      content:d.body.content
    })
  });

  if(data['@odata.nextLink']) {
    return await getCompletedToDos(todos, data['@odata.nextLink']);
  } else return todos;
  
}

return await getCompletedToDos();
steps.
nodejs
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
}
9
$respond({
  status:200,
  headers: {
    'Content-Type':'application/json'
  },
  body:steps.getToDos.$return_value
})