This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="mailto:[email protected]?subject=Hello&body=We+want+to+hire+you">Contact Us</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="mailto:[email protected]">Contact Us</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/github').create(); | |
(async () => { | |
let newIssue = await github.repos.owner.repo.issues.post({ | |
owner: 'torvalids', | |
repo: 'linux', | |
body: { | |
title: "Fix the thing!", | |
body: "It's broke", | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/hacker_news').create(); | |
let firstUser = null; | |
let secondUser = null; | |
Promise.resolve() | |
.then(_ => hn.getUser({username: 'sama'})) | |
.then(user => { | |
firstUser = user; | |
return hn.getUser({username: 'pg'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/hacker_news').create(); | |
(async () => { | |
let users = await Promise.all([ | |
hn.getUser({username: 'sama'}), | |
hn.getUser({username: 'pg'}), | |
]); | |
let [more, less] = users.sort((a, b) => b.karma - a.karma); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/hacker_news').create(); | |
(async () => { | |
let user1 = await hn.getUser({username: 'sama'}); | |
let user2 = await hn.getUser({username: 'pg'}); | |
let [more, less] = [user1, user2].sort((a, b) => b.karma - a.karma); | |
console.log(`${more.id} has more karma (${more.karma}) than ${less.id} (${less.karma})`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/hacker_news').create(); | |
(async () => { | |
let storyIDs = await hn.getStories({storyType: 'top'}); | |
// Using for loop (runs in series) | |
for (let itemID of storyIDs) { | |
let details = await hn.getItem({itemID}); | |
console.log(details); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/hacker_news').create(); | |
(async () => { | |
let storyIDs = await hn.getStories({storyType: 'top'}); | |
storyIDs.forEach(async itemID => { | |
let details = await hn.getItem({itemID}); | |
console.log(details); | |
}); | |
console.log('done!'); // Wrong! This will run before all the calls to getItem() are done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BEATLES = ['john', 'paul', 'george', 'ringo']; | |
// Regular for loop: | |
for (let i = 0; i < BEATLES.length; ++i) { | |
console.log(BEATLES[i]); | |
} | |
// With Array.forEach: | |
BEATLES.forEach(beatle => console.log(beatle)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let hn = require('@datafire/hacker_news').create(); | |
// Old code with promises: | |
Promise.resolve() | |
.then(_ => hn.getStories({storyType: 'top'})) | |
.then(storyIDs => hn.getItem({itemID: storyIDs[0])) | |
.then(topStory => console.log(topStory)) | |
.catch(e => console.error(e)) | |
// New code with async: |