Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda