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

88
Views
how to use request response in another request

I'm trying to use the first express request and response data to the second request, the problem is that both requests need to have their own body data in case I want to use them in the frontend node, is there any efficient approach to solve this issue. in my below requests code, I must use the uploadlink from the first request to the second request.

const ThumbnailUploadlink = async (req, res) => {
  const { videoId } = req.body;
  const clientServerOptions11 = {
    uri: `https://api.vimeo.com/videos/${videoId}/pictures`,
    body: JSON.stringify({
      name: videoId,
    }),
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Accept: 'application/vnd.vimeo.*+json;version=3.4',
      Authorization: getVimeoAuthorization(),
    },
  };
  request(clientServerOptions11, function (error, response) {
    if (error) {
      res.send(error);
    } else {
      const body = JSON.parse(response.body);
      res.send(body);
      const uploadLink = body.link;

      console.log(uploadLink);
    }
  });
};

// uploadLink must take value from previous request
const ThumbnailUpload = async (req, res, uploadLink) => {
  const { selectedFile } = req.body;
  const clientServerOptions = {
    url: `${uploadLink}`,
    body: JSON.stringify({
      name1: selectedFile,
    }),
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      Accept: 'application/vnd.vimeo.*+json;version=3.4',
      Authorization: getVimeoAuthorization(),
    },
  };
  request(clientServerOptions, function (error, response) {
    if (error) {
      res.send(error);
      console.log(uploadLink);
    } else {
      const body = JSON.parse(response.body);
      res.send(body);
      console.log(uploadLink);
    }
  });
};
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!