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

158
Views
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
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!