Skip to content

Instantly share code, notes, and snippets.

@blacksheep557
Created April 19, 2021 11:19
Show Gist options
  • Select an option

  • Save blacksheep557/ab8e7ab82af28b776eea0d3f0fca8899 to your computer and use it in GitHub Desktop.

Select an option

Save blacksheep557/ab8e7ab82af28b776eea0d3f0fca8899 to your computer and use it in GitHub Desktop.
const request = require("request");
function getContacts() {
// we have a max of 50 pages
const options = (page) => ({
url: `https://api.jurnal.id/core/api/v1/contacts?contact_index={"curr_page":${page},"selected_tab":1,"sort_asc":true,"show_archive":false}`,
headers: {
'apikey': /// TODO: add apikey here
}
});
const jurnalContacts = {};
for (let i = 0; i < 51; i++) {
request.get(options(i), function (err, resp, body) {
if (err) {
console.log(`There was an error ${err}`);
} else {
const body = JSON.parse(resp.body)
const personList = body.contact_list.contact_data.person_data
personList.forEach(p => {
jurnalContacts[p.display_name] = {name:p.display_name, id: p.person_id}
})
console.log(jurnalContacts)
}
})
}
}
getContacts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment