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

151
Vistas
Vue.js 2 Set all reactive properties from API call

I have a vue component with some properties eg.

import { getAPI } from "@/axios-api";
import { mapGetters, mapActions } from "vuex";
export default {
  name: "edit-profile-form",
  data() {
    return {
      first_name: "",
      last_name: "",
...

I also have an API call that will get these properties, which have exactly the same name eg.

{
   "first_name": "Jon",
   "last_name": "Doe"
}

Is there a way I can update both properties simultaneously? instead of doing

axios.get('/url/').then(res => {
  this.first_name = res.first_name;
  this.first_name = res.first_name;
});

Thanks

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

0

A quick way to copy those fields into your data is to use Object.assign():

axios.get('/url/').then(res => {
  Object.assign(this.$data, res.data)
});

demo

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