title: how do I access the value of an attribute inside an object using cheerio
body: <p>I'm trying to push the values of an attribute("data-code") into an array using cheerio.  However, I keep getting the error message "allAs[i].attr is not a function"</p>
  
  <p>Here's what I have so far</p>
  
  <pre><code>const express = require('express');
  const request = require('request');
  const cheerio = require('cheerio');
  const app = express();
  
  app.get('/scrape', (req, res) =&gt; {
      const url = 'http://store.emart.com/branch/list.do?id=1702';    
  
      request(url, (err, response, body) =&gt; {
          if(!err) {
              var idList = [];
              console.log(typeof(idList));
              var $ = cheerio.load(body);
              var allAs = $("a").filter("[data-code]");
              console.log(allAs[0].val);
              for(var i = 0; i &lt; allAs.length; i++){
                  //console.log(allAs[i]);
                 idList.push(allAs[i].attr("[data-code]"));
              }
              console.log();
  
              res.send(body);
          } else {
              console.log("problems yo");
          }
      });
  });
  
  
  app.listen(3000, () =&gt; {
      console.log("Server is up and running!!!");
  });
  </code></pre>
  
  <p>There should be 330 results pushed into idList.  </p>