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

173
Views
Convertir una función en una promesa

Tengo una función que tarda un tiempo en completarse, por eso quiero convertirla en una promesa.

  • Mi objetivo es poder llamar a la función/promesa y, una vez que se cumpla, puedo usar un .then() para hacer lo que quiera.

  • Quiero que se getPlantMaterials() , después de recibir la respuesta de la API.

Sin embargo, no estoy seguro de cómo convertir esto correctamente en una promesa:

 getPlantMaterials() { this.isLoadingPlantMaterials = true; this.$apollo .query({ query: gql` query getMaterialByPotSizeId($plantPotSizeId: ID) { tenantPlantMaterials( plantPotSize_Id: $plantPotSizeId ) { edges { node { id quantity material { id name materialType { name id } brand vendor size unit inventory id } } } totalCount } } `, variables: { plantPotSizeId: this.selectedPlant.plantPotSize.id, materialId: null, quantity: null } }) .then(response => { this.selectedPlantMaterials = response.data.tenantPlantMaterials.edges; this.selectedPlantMaterials.map(item => { item.node.totalAmount = item.node.quantity * this.totalPlantQuantity; }); console.log( "this.selectedPlantMaterials", this.selectedPlantMaterials ); }) .finally(() => { this.isLoadingPlantMaterials = false; }); },
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!