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

135
Vistas
Devolver objeto JSON por ID de otro JSON

Tengo 2 recursos API:

  1. http://127.0.0.1:8000/api/citas con JSON
 { "id": 771, "title": "Call to Alyce Herman - Engine Assembler", "assigned_with_person_id": 317, }
  1. http://127.0.0.1:8000/api/personas con JSON:
 { "id": 317, "forename": "Lauriane", "name": "Jude Greenfelder", "oral_coach": 0, "coordinator": 0, "phone": "+32 2737515", "get_organisation": { "id": 5, "name": "Sauer-Becker", "city": "North Anne", "region": "Trinidad and Tobago", "street": 0, "number": 745, "postbox": null, "postcode": 26791 } }
 <template> <!-- How to put here organization name where are working person (assigned_with_person_id) with ID 317 ? --> {{ currentPerson.get_organisation.name }} </template> <script> export default { data() { return { currentAppointment: {}, currentPerson: '', } }, created () { this.axios .get(`/api/appointments/${this.$route.params.id}`) .then((response) => {this.currentAppointment = response.data;}); }, mounted() { this.getCurrentPerson(); }, methods: { getCurrentPerson() { let personId = /*how to find and put here assigned_with_person_id from JSON of currentAppointment*/; axios.get(`/api/persons/${personId}`) .then(response => (this.currentPerson = response.data)) .catch(error => console.log(error)); } } } </script>

¿Cómo encontrar la asignación_con_persona_id de Citas-JSON y encontrar a esta persona en Personas-JSON, luego poner el nombre de la organización de esta persona en la plantilla Vue?

¡Gracias!

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

0

El problema se ha solucionado con este código:

 currentPersonFn() { this.axios //get current Appointment by ID from params .get(`/api/appointments/${this.$route.params.id}`) .then((response) => { this.currentPID = response.data.assigned_with_person_id; // return only assigned_with_person_id // put ID of Person into nested axios.get axios.get(`/api/persons/${this.currentPID}`) .then(response => { this.currentPerson = response.data //console.log(response.data) }); }); },
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