WolfGrayy

Untitled

Mar 15th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //This is right after getPosts()
  2. let authorURLS = [];
  3. let LinkKarmas = [];
  4. let CommentKarmas = [];
  5. let jsonProfiles = {};
  6. profiles = [];
  7. async function finish(){
  8.   await getPosts(search);
  9. console.log(authors.length)
  10. var i;
  11. for(i = 0; i< authors.length; i++){
  12.   authorURLS[i] ="https://www.reddit.com/user/" + authors[i] + "/about.json";
  13.   console.log(authorURLS[i]);
  14.   getKarmas(authorURLS)
  15.   function getKarmas(authorURLS){
  16.     let authorProfileLink = authorURLS[i];
  17.     console.log(authorProfileLink);
  18.     return fetch(authorProfileLink)
  19.       .then(res => res.json())
  20.       .then(profiles => {
  21.         // Get request is done
  22.         jsonProfiles = profiles;
  23.         console.log("This is the raw result json object:");
  24.         console.log(jsonProfiles);
  25.  
  26.         // Extract and print posts
  27.         profiles = jsonProfiles.data.children.map((o) => o.data);
  28.         console.log("This is the profile for this author:");
  29.         console.log(profiles);
  30.  
  31.         // Extract and print authors
  32.         LinkKarmas = jsonProfiles.data.children.map((o) => o.data.link_karma);
  33.         console.log("This is the link karma for this person:");
  34.         console.log(LinkKarmas);
  35.  
  36.         CommentKarmas = jsonPost.data.children.map((o) => o.data.title);
  37.         console.log("This is the comment karma for this person:");
  38.         console.log(CommentKarmas);
  39.     });
  40.   }
  41.  
  42. }
  43.  
  44. }
  45.  
  46. finish();
Advertisement
Add Comment
Please, Sign In to add comment