Home > Enterprise >  Storing Array Values to Objects Only Stores first value and keeps Repeating the Value Over And Over
Storing Array Values to Objects Only Stores first value and keeps Repeating the Value Over And Over

Time:12-22

Im new to JavaScript so I dont have good Programming Skills rightnow, so I have been working on a Web Scraper That returns an Array of Name,Posts,Bio etc like this:

let infoOfPost = await newTab(browser, page);

So infoOfPost is an Array whose value is changinging since it is being called in a loop and i can see it in console that every time it has new values for bio,posts,followers etc. But when I push this value to an Object, the Object only store the initial value when loop ran for the first time and in every next iteration it just keeps displaying same value and does not overwrites the previous value Im storing array in objec as:

    accountInfoObject.displayName =infoOfPost[0];
    accountInfoObject.posts = infoOfPost[1];
    accountInfoObject.followers=infoOfPost[2];
    accountInfoObject.following =infoOfPost[3];
    accountInfoObject.fullName = infoOfPost[4];
    accountInfoObject.about =infoOfPost[5];
    accountsInformation.push(accountInfoObject);
    await objectsCsv(accountsInformation);

What Im seeing right now is something like this:

[
 {
   accountUrl: 'https://www.example.com/xyz.hij/',
   displayName: 'saharpalmer',
   posts: '368',
   followers: '2,640',
   following: '510',
   fullName: 'Sahar Intuitive Life Mentor',
   about: '30-year Experience: I help you shift your mindset           
  • Related