Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
Vue Js: empty string when posting to API

in my below code .. i'm updating data using Node Js REST API and in remaining field i have set an equation using v-model=remaininginst to keep track of the result and save it into remaininginst so i can post it to API, but on console.log i'm getting NaN empty data stored in remaininginst and it's not posting due to this error..

am i doing something wrong here? and if yes is there a way to do it?

 <h4 v-model="remaininginst"> remain : ${{ Number(instPrice) -(Number(totPaid) + Number(instOne) )  }}</h4> //equation shows coorect data on html
                                        
 
</template>

export default {
    name: 'light-table',
    components: {
loader
    },
    data() {
        return {
   
            instPrice: "",
            remaininginst:  "",
            instOne:""
            

        };
    },
    computed: {

        totPaid() {
            let installments = this.Flats.payment.installment_payment.installments;
            let paidInstallments = installments.filter(obj => obj.is_paid == true);
            let totalPaid = paidInstallments.reduce((sum, obj) => sum + parseInt(obj.amount), 0);
            return totalPaid;
        }

    },
    methods: {
      

        PostPayment() {
            this.error = []
            console.log(this.payment);

            var data = {
                payment: {
                    installment_payment: {
                  

                  remaining: this.remaininginst,//getting Nan

                    },
                    paid_amount: this.instOne,
                },
            }
           

            BuildingsService.Payment(this.FlatId, data).then((response) => {
                console.log(data);
              
            });
        

        },

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could not use v-model on h4 tag.You could try to create another computed property which contains the expression you need and show it on view.Below sample move remaininginst from data to computed as a computed property.

 <template>
  <h4>
    remain : $ {{ remaininginst }}
  </h4>
</template>
<script>
export default {
  data() {
    return {
      instPrice: "",
      instOne: "",
    };
  },
  computed: {
    totPaid() {
            let installments = this.Flats.payment.installment_payment.installments;
            let paidInstallments = installments.filter(obj => obj.is_paid == true);
            let totalPaid = paidInstallments.reduce((sum, obj) => sum + parseInt(obj.amount), 0);
            return totalPaid;
        }

    remaininginst() {
      return (
        Number(this.instPrice) - (Number(this.totPaid) + Number(this.instOne))
      );//return any string you want
    },
  },
  methods: {
    PostPayment() {
      console.log(this.remaininginst);
    },
  },
};
</script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda