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

246
Views
Upload files VueJS to NodeJS backend by axios

I would like to upload a file in vuejs to my nodejs server. However, I can't receive my file in the backend. Someone could help me. I have tried several things but I still can't get it. If anyone can help me I would be very grateful :-)

VueJS Upload Page Code

<input id="input-file" name="input-file" type="file" ref="file" @change="newFile($event)"/>
const formData = new FormData();
formData.append("file", document.getElementById("input-file"))
const createUserResponse = await RequestManager.executePostRequest("/users/upload", formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
});

RequestManager executePostRequest Function

static async executePostRequest(url: string, params: any, specialConfig?: AxiosRequestConfig) {
        const postToken = Utils.buildHmacSha256Signature(params);
        let headers: AxiosRequestHeaders = {
            "x-access-token": config.server.backendAccessToken,
        }

        if (RequestManager.token) {
            headers = {
                "x-access-token": config.server.backendAccessToken,
                "x-token-data": RequestManager.token,
            }
        }
        if (specialConfig && specialConfig.headers) {
            headers = Utils.mergeObjects(headers, specialConfig.headers) as AxiosRequestHeaders;
        }

        const instance = axios.create({
            baseURL: config.server.host,
            headers: headers
        });
        console.log(headers);

        const paramsPost = {
            data: params,
            token: postToken
        }

        return new Promise<any>((resolve, reject) => {
            instance
                .post(url, paramsPost)
                .then(response => {
                    resolve(response.data);
                })
                .catch(error => {
                    reject(error);
                });
        });
    }

Backend NodeJS

UserRouter.get("/upload", (req, res) => {
  console.log(req.files);
  res.send("ok");
});
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!