Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel authored Mar 7, 2024
1 parent 23f268f commit 227a222
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@ Using this **simple custom code**:

```ts
export default async function fetchData(nango: NangoSync) {
const reposResponse = await nango.get({
endpoint: '/user/repos'
});
const repos = reposResponse.data;

for (const repo of repos) {
const issuesResponse = await nango.get({
endpoint: `/repos/${repo.owner.login}/${repo.name}/issues`,
});

let issues = issuesResponse.data.filter((issue: any) => !('pull_request' in issue));

if (issues.length > 0) {
await nango.batchSave(issues, 'Issue');
await nango.log(`Sent ${issues.length} issues from ${repo.owner.login}/${repo.name}`);
}
}
// Fetch issues from GitHub.
const res = await nango.get({ '/repos/NangoHQ/interactive-demo/issues' });

// Map issues to your preferred schema.
const issues = res.data.map(issue => ({ id, title, url }));

// Persist issues to the Nango cache.
await nango.batchSave(issues, 'Issue');
}
```

Expand Down

0 comments on commit 227a222

Please sign in to comment.