text: //Todo
  //this is a base app from tutorial need to make the following modifications
  //modify the below to take in speciifc lead/contact params
  //testing on single example
  //read in the csv file
  //generate a for loop for url function and implement into scraper
  
  const PORT = 8000
  const axios = require('axios')
  const cheerio = require('cheerio')
  const express = require('express')
  const app = express()
  const cors = require('cors')
  app.use(cors())
  
  //file must be located in the assets folder of this project and called 'CompanyorInsitution' with a csv file extension
  //todo; fix loadTable Error
  /*
  function setup() {
      loadTable('assets/data.csv','header',loaded);
    }
    
    function loaded(table) {
      data = table;
      for (var i = 0; i < table.rows.length; i++) {
        console.log(data.rows[i].get('name'));
      }
    }
  */
  
  const url = 'https://www.theguardian.com/uk'
  
  app.get('/', function (req, res) {
      res.json('This is my webscraper')
  })
  
  app.get('/results', (req, res) => {
  
  //pass the url through axios 
      axios(url)
          .then(response => {
              //save the response data, which gives us all of the site's html
              const html = response.data
              const $ = cheerio.load(html)
              const articles = []
              //selects the html element the class name needed, then for each get the item and get the text tag and the url
              $('.fc-item__title', html).each(function () { //<-- cannot be a function expression
                  const title = $(this).text()
                  const url = $(this).find('a').attr('href')
                  //push the elements of the webpage to the array
                  articles.push({
                      title,
                      url
                  })
              })
              res.json(articles)
          //error catching
          }).catch(err => console.log(err))
  
  })
  //setup()
  //run the app
  app.listen(PORT, () => console.log(`server running on PORT ${PORT}`))
  
  
  