I have a completed script that acts as a parser. The script is written in NodeJS and it works properly. The script returns an array of data and also saves it to my computer.
I would like to run this script from the frontend, at the click of a button. As far as I understand, I have to send a request to the server? It’s suggested to use Express for the server, but I still haven’t figured out how to call a third-party script from it, much less return any data from it.
Right now all I want is for my script to run when I make a request for the root directory “/” and send me a json in response (or for example a json file)
const express = require('express')
const runParser = require("./parser");
const app = express()
const port = 3000
const doParse=async(req,res,next)=>{
await runParser()
}
app.get('/', async (req, res,next) => {
await doParse(req,res)
next()
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})