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

182
Views
Not able to send image to post API request in vuejs after uploading the file

I am trying to send uploaded image to the backend and using this approach to send it and inside apiendpoints there are many apis defined and through one of the end points I am trying to pass that image but at the end i am getting 504 error.

<template>
         <div class="row">
            <input type="file" @change="previewImage" accept="image/*" />
          </div>
        </template>
        
    <script>
        import { apiEndpoints } from '../../../../../utils/constants';
        Vue.use(Vuetify);
            
        export default {
          name: 'SwapOnboardingStepTwo',
          data: () => ({
            imageData: '',
          }),
          methods: {
            previewImage: function (event) {
              var input = event.target;
              if (input.files && input.files[0]) {
                var reader = new FileReader();
                reader.onload = (e) => {
                  this.imageData = e.target.result;
                };
                reader.readAsDataURL(input.files[0]);
              }
            },
             onUpload() {
              const fd = new FormData();
              fd.append('image', this.imageData)
            const body = {
            agreementImage: fd
          };
          try {
            const response = await this.$energyAxios.post(
              apiEndpoints.vehicleOnboard,
              body
            }
          },
        };
     </script>

here I'm not able to send fd that is image to post API

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!