Skip to content

Instantly share code, notes, and snippets.

@orthros
Created August 25, 2017 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orthros/3b9e1ee333f881c30b3b4b225ed87833 to your computer and use it in GitHub Desktop.
Save orthros/3b9e1ee333f881c30b3b4b225ed87833 to your computer and use it in GitHub Desktop.
const client = new stitch.StitchClient(APP_ID);
const db = client.service('mongodb', 'mongodb-atlas')
.db(APP_DB);
function displayIssuesOnLoad() {
client.authenticate('apiKey', APP_API_KEY)
.then(displayIssues);
}
function displayIssues() {
db.collection(APP_COLLECTION)
.find({ }, { limit: 10 })
.then(docs => {
console.log(docs);
var html = docs.map(c => `<div class="center-block">
<hr>
<div class="center-block text-center">Issue: <a href="${c.issue.issue.html_url}">${c.issue.issue.title}</a></div>
<div class="text-center">Comments: ${c.issue.issue.comments}</div>
<div class="text-center">
Repository:
<a href="${c.issue.repository.html_url}">${c.issue.repository.name}</a>
</div>
<hr>
</div>`)
.join("");
document.getElementById("issues").innerHTML = html;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment