TypeError: Assignment to constant variable, when trying to create an array of objects

I’ve been working on a scraper and all was good until I’ve tried to push objects of scraped data into an array.

Right now I have this:

exports.parseData = (getLink, getDescription, getPrice, getPicture) => {
  const apartments = [];
  apartments = {
    link: getLink,
    descr: getDescription,
    price: getPrice,
    picture: getPicture,

But it throws an error: TypeError: Assignment to constant variable.

Now I think this is happening because of how data is sent to a parser.
Here is how data looks when I use this code:

exports.parseData = (getLink, getDescription, getPrice, getPicture) => {

 dvosoban stan sa liftom u samom centru grada , 63 m2 
 Troiposoban stan u naselju Sunca
 trosoban, renoviran stan u naselju Dolac malta, 73 m2
 Četverosoban stan u novogradnji sa prelijepim pogledom na grad, 118,38 m2 
 Trosoban stan u novogradnji sa prelijepim pogledom na grad, 105,34 m2
 Luksuzni četverosoban stan na Čobaniji,117,43m2
 trosoban stan u novogradnji, 90 m2

Now what my desired output would be: To have an array of objects, where objects are filled with data like it’s shown in example above. So for each getLink, getDescription, getPrice, getPicture create new object and push it into an array(like I’m using it in the first code block).

Output that I would like to get is:

      link: https://www.sant.ba/nekretnine/nekretnina-3467-dvosoban-stan-sa-liftom-u-samom-centru-grada-63-m2
      descr: dvosoban stan sa liftom u samom centru grada , 63 m2 
      price: 199000.00
       picture: https://www.sant.ba/thumb.php?file=photos/3467/3467_1_1563271355.jpg&maxw=273&maxh=205
     descr: Troiposoban stan u naselju Sunca
     price: 360000.00
     picture: https://www.sant.ba/thumb.php?file=photos/3689/3689_1_1612344465.jpg&maxw=273&maxh=205

Is something like this easy to achieve?

Here is from where these variables are sent:

const cheerio = require('cheerio');
const axios = require('axios');
const parsing = require('./parseData');

exports.olxScraper = () => {
  const url =

  const getRawData = async () => {
    try {
      await axios.get(url).then((res) => {
        const $ = cheerio.load(res.data);
        $('div[id="rezultatipretrage"] > div')
          .not('div[class="listitem artikal obicniArtikal  i index"]')
          .each((index, element) => {
            const getLink = $(element)
              .find('div[class="naslov"] > a')
            const getDescription = $(element)
              .find('div[class="naslov"] > a > p')
            const getPrice = $(element)
              .find('div[class="datum"] > span')
              .replace(/\.| ?KM$/g, '')
              .replace(' ', '');
            const getPicture = $(element)
              .find('div[class="slika"] > img')

            parsing.parseData(getLink, getDescription, getPrice, getPicture);
    } catch (error) {

exports.santScraper = () => {
  const url = `https://www.sant.ba/pretraga/prodaja-1/tip-2/cijena_min-20000/stranica-1`;

  const getRawData = async () => {
    try {
      await axios.get(url).then((response) => {
        const $ = cheerio.load(response.data);

        $('div[class="col-xxs-12 col-xss-6 col-xs-6 col-sm-6 col-lg-4"]').each(
          (index, element) => {
            const getLink = $(element).find('a[class="re-image"]').attr('href');
            const getDescription = $(element).find('a[class="title"]').text();
            const getPrice = $(element)
              .find('div[class="prices"] > h3[class="price"]')
              .replace(/\.| ?KM$/g, '')
              .replace(',', '.');
            const getPicture = $(element).find('img').attr('data-original');
            /*const getSquaremeters = $(element)
        .replace(',', '.')

      const pricepersquaremeter =
        parseFloat(getPrice) / parseFloat(getSquaremeters);
      articles[index] = {
        id: getLink.substring(42, 46),
        link: getLink,
        descr: getDescription,
        price: Math.round(getPrice),
        pictures: getPicture,
        sqm: Math.round(getSquaremeters),
        ppm2: Math.round(pricepersquaremeter),
            parsing.parseData(getLink, getDescription, getPrice, getPicture);
    } catch (error) {


165 thoughts on “TypeError: Assignment to constant variable, when trying to create an array of objects”

  1. pharmacie de garde ouverte aujourd’hui hyeres pharmacie ouverte xertigny , pharmacie x rousse pharmacie bourges nord , Barato Acivir en Ecuador, DГіnde comprar Acivir 200 mg. Comprar Acivir sin receta Comprar Acivir genГ©rico [url=https://kit.co/lucosri/acivir-en-farmacia-ecuador-barato-acivir-en-ecuador#]Comprar Acivir genГ©rico[/url] pharmacie ouverte ile d’oleron Comprar Lexapro medicamento, DГіnde comprar Lexapro 10 mg. Comprar Lexapro sin receta Comprar Lexapro genГ©rico [url=https://kit.co/veculci/comprar-lexapro-medicamento-lexapro-en-farmacia-miami#]Comprar Lexapro genГ©rico[/url] , therapies systemiques familiales pharmacie leclerc erstein , therapie comportementale et cognitive toulouse. pharmacie leclerc nord pharmacie annecy albigny DГіnde comprar Bupropion 150 mg, Comprar Bupropion medicamento. Comprar Bupropion sin receta Comprar Bupropion genГ©rico [url=https://kit.co/ofpruper/donde-comprar-bupropion-150-mg-barato-bupropion-en-espana#]DГіnde comprar Bupropion 150 mg[/url] , medicaments utilises en soins palliatifs. pharmacie de garde marseille 6, pharmacie auchan gien pharmacie guillot avignon . pharmacie amiens ouvert dimanche, pharmacie houdan therapie genique cancer pharmacie kremlin bicetre .

  2. therapie de couple bordeaux pharmacie beauvais st lucien , pharmacie colmar pharmacie bordeaux ginko , Tadapox en farmacia Chile, DГіnde comprar Tadapox 80 mg. Comprar Tadapox sin receta Comprar Tadapox genГ©rico [url=https://kit.co/neumohun/tadapox-en-farmacia-chile-comprar-tadapox-sin-receta#]Comprar Tadapox sin receta[/url] pharmacie ouverte tours Comprar Tricor genГ©rico, DГіnde comprar Tricor 160 mg. Comprar Tricor sin receta Comprar Tricor genГ©rico [url=https://kit.co/quedinigh/donde-comprar-tricor-160-mg-comprar-tricor-generico#]Tricor en farmacia Guatemala[/url] , act therapy for depression pharmacie ouverte nice , pharmacie auchan buchelay. pharmacie basilique argenteuil therapies alternatives geneve Comprar Tadora medicamento, Comprar Tadora medicamento. Tadora en farmacia Argentina Comprar Tadora genГ©rico [url=https://kit.co/riorosuc/comprar-tadora-medicamento-tadora-en-farmacia-argentina#]Comprar Tadora genГ©rico[/url] , therapies act. therapies de conversion arte, pharmacie aix en provence jas de bouffan traitement gingivite . therapies cognitivo-comportementales exemple, raw therapee salon des therapies alternatives lorient pharmacie angers rue paul bert .

  3. Pingback: sildenafil
  4. Pingback: viagra buy online
  5. Pingback: viagra for sale
  6. Pingback: cialis 20
  7. Pingback: free viagra
  8. Pingback: herbal viagra
  9. Pingback: viagra alternative
  10. Pingback: cheapest viagra
  11. Pingback: sildenafil generic
  12. Heya i am for the first time here. I came across this
    board and I find It truly useful & it helped me out a lot.
    I hope to give something back and aid others like you
    helped me.

  13. Excellent blog here! Also your site loads up very fast!
    What host are you using? Can I get your affiliate link to your host?
    I wish my website loaded up as fast as yours lol

  14. Pingback: tadalafil citrate
  15. Pingback: sildenafil 100mg
  16. hey there and thank you for your info – I have certainly picked up anything new from right here.

    I did however expertise some technical issues using
    this web site, as I experienced to reload the web site lots of times previous to I could get it to load properly.

    I had been wondering if your web host is OK? Not that I’m complaining, but slow loading instances times will often affect your placement in google and could damage your quality score if ads and marketing with Adwords.
    Anyway I am adding this RSS to my email and could look out for much more
    of your respective fascinating content. Make sure you update this
    again very soon. http://ciaalis2u.com/