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

273
Views
how to fix uri undefined error when trying to send request

when I'm trying to call the request in front node, I'm getting error in my backend node " RequestError: Error: Invalid URI "undefined"" , it seems like backend node request is not getting the data form my frontend node request. knowing that uploadLink already have a value and in my browser console the frontend request looks ok enter image description here my backend request code

const ThumbnailUpload = async (req, res) => {
  const { Uploadlink } = req.body;
  const { selectedFile } = req.body;
  const clientServerOptions = {
    uri: `${Uploadlink}`,
    body: JSON.stringify({
      name: 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);
    } else {
      const body = JSON.parse(response.body);
      res.send(body);
    }
    console.log(Uploadlink);
  });
};

and my frontend code is

const handleSubmit = (event) => {
    event.preventDefault();
    const formData = new FormData();
    formData.append(
      'selectedFile',
      new Blob([selectedFile], { type: 'image/jpg, image/png, or image/gif' }),
    );
    formData.append('uploadLink', uploadLink);

    const headers = {
      'Content-Type': 'image/jpg, image/png, or image/gif',
      Accept: 'application/vnd.vimeo.*+json;version=3.4',
    };

    try {
      axios
        .post(`${backendPostPath}/thumbnail-upload`, formData, {
          headers,
        })
        .then((response) => {
          applyThumbnial();
          console.log(response);
        });
    } catch (error) {
      console.log(error);
    }
  };

any advise ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

change:

const { Uploadlink } = req.body;

to:

const { uploadlink } = req.body;

make variable consistent throughout the code

EDIT

also, since you're uploading a file, you need to use upload middleware before request handler, and file will be within req.file:

route.post('/thumbnail-upload', upload.single('selectedFile'), ThumbnailUpload);

//... handler..
const selectedFile = req.file;
about 4 years ago · Juan Pablo Isaza Report
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!