0

Before anything, its my first question on stackoverflow, so im sorry if something isnt
correct.

Here is my repository: https://github.com/Ellisarm/FLASH Details about the app: in index.js file i am using express and i am importing from scrapers.js and meciuri&ids.js 2 functions in which i am scraping 2 arrays. Each functions is used with either app.post or app.get. I assigned a path also to them.

So basically, i want to enter on a http and get some data from there, data which is scraped thanks to puppeteer.

I've tried to deploy the application on heroku, but i didnt recieve the data, i have errors. I've made a lot of research before questioning this...

THIS is my index.js file

const express = require('express')
const cors = require('cors')
const scrapeProduct = require('./scrapers.js')
const scrapeProductSecond = require('./meciuri&ids.js')
const app = express()
const port =  8081

app.use(cors())

app.use(express.json())

app.post('/puppeteer', async (req, res) => {
    const cote = await scrapeProduct(req.body.url)
    
    console.log(cote);
    res.status(201).send(cote)
   
    
})

app.get('/', async(req, res) =>{
    const {echipeAcasa} = await scrapeProductSecond()
    const {echipeDeplasare} = await scrapeProductSecond()
    const {theIds} = await scrapeProductSecond() 
    console.log(typeof echipeAcasa, typeof echipeDeplasare, typeof theIds);
    console.log( echipeAcasa,  echipeDeplasare,  theIds);
    res.status(201).send([echipeAcasa, echipeDeplasare, theIds])
})

app.listen(process.env.PORT || port, ()=> console.log("Example app listening on port " + port))

I would appreciate even a link where i can research more or even a idea... thanks

Tom Ghe
  • 15
  • 4
  • 1
    `i have errors`. Could you show them? – Keith Oct 26 '21 at 08:53
  • i wanted to say that i cant get the data from the herokuapp link... also in herokuapp logs it says that it cant launch the browser and cant call the method get – Tom Ghe Oct 26 '21 at 10:15
  • 1
    Try to include the actual error message too :) I am suggesting to close this as a duplicate, because it seems really familiar to an older question, please check it out – Joel Peltonen Oct 26 '21 at 11:33
  • 1
    Does this answer your question? [Puppeteer unable to run on heroku](https://stackoverflow.com/questions/52225461/puppeteer-unable-to-run-on-heroku) – Joel Peltonen Oct 26 '21 at 11:33
  • 1
    Also, generally file names like `meciuri&ids.js` maybe should be avoided, that can cause issues in some environments. And lastly, in these situations I would try to make a very minimalistic example where the bug/issue happens and test using just that; that way your question will have only the relevant code too – Joel Peltonen Oct 26 '21 at 11:35

0 Answers0