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

165
Vistas
Access Value from One Function and Pass Into Another Function Using Express Post Request

So I have these functions and passing the value into another function works fine with regular javascript functions. My problem is passing this same value through post request on express.

Here is the regular JS functions without express that currently works

Inside of one file called quote.js I have this code that generates a random ID

export const response = await client.deliveryQuote({
  external_delivery_id: uuidv4(),
});

console.log(response);

Then in another file called quoteNew.js I have this code which receives the value from the quote.js file and gets the external_delivery_id value

import { response } from "./quote.js";

const response1 = client
  .deliveryQuoteAccept(response.data.external_delivery_id)
  .then((resp) => {
    console.log(resp);
  })
  .catch((err) => {
    console.log(err);
  });

console.log(response1);

So this code above works perfectly fine when getting the external_delivery_id value.

Now what I want to do is replicate this same thing except using express.

So in my server.js file I have this code. When I add this code response.data.external_delivery_id into the deliveryQuoteAccept it doesn't work the same and says response is not defined since it can't access the response value from the app.post get-quote function

Right now it just says response is not defined when passing it into the 2nd app.post function

app.post("/get-quote", async (req, res) => {
  const response = await client.deliveryQuote({
    external_delivery_id: uuidv4(),
  });

  res.send(response);
});


app.post("/accept-quote", (req, res) => {
  const response1 = client
    .deliveryQuoteAccept(response.data.external_delivery_id) //response is not defined
    .then((response) => {
      console.log("Delivery Created", response);
    })
    .catch((err) => {
      console.log(err);
    });

  console.log("ACCEPT", response1);
 })

How do I access the response value from the first app.post function and transfer it into my 2nd app.post function in this section

const response1 = client
    .deliveryQuoteAccept(I NEED THE EXTERNAL_DELIVERY_ID VALUE HERE)
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