Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Run axios code made in Node in Javascripts

The following code that I have made in node works perfectly, what it does is bring me a pdf report from JasperReports Server, however, I would like to try to achieve this but without the use of Node, I have done the following but without any success, if someone can Help me with this I would really appreciate it.

Node:

app.post('/form-submit', async function (req, res) {
    try {
        const url = "http://localhost:8080/jasperserver/rest_v2/reports/reports/R011.pdf" 
        var params = {
            FF:"1234"
        }
        const file = await axios.get(url, {
            params: params,
            responseType: "stream",
            auth: {
                username: "JASPER",
                password: "JASPER"
            }
        })
        res.writeHead(200, { "Content-Type": "application/pdf"})
        file.data.pipe(res)
    } catch (error) {
        console.log(error)
    }
});

Javascript

const prueba = async() => {
    try {
        const respuesta = await axios.get("http://localhost:8080/jasperserver/rest_v2/reports/reports/R011.pdf", {
            params: {
                FF:"1234"
            },
            headers: {
                auth: {
                    username: "JASPER",
                    password: "JASPER"
                } 
            },
            responseType: "stream",
        })
    } catch (error) {
        
    }
}
prueba()

Html:

<body>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="/index.js"></script>
</body>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!