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

100
Views
¿Cómo devolver las propiedades de un objeto de respuesta junto con un nuevo objeto?

Así que estoy haciendo una solicitud POST así:

 async createVisit(patientId: string, visitorId: string) { const userJWT = jwt.sign( { _id: visit, refreshCount: 0 }, this.localConfig.spirit.jwtSecret ) const visitURL = this.localConfig.spirit.url let response = await fetch(visitURL, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer' + userJWT }, body: JSON.stringify(visit) }); if (response.ok) { let result = await response.json(); } }

Así que necesito devolver un par de propiedades de ese result junto con un nuevo objeto para acceder dentro del método de otra clase.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solo puede devolver 1 cosa de una función, pero si necesita devolver 2 cosas, puede combinarlas en una matriz

 return [coupleOfPropertiesFromResult, newObject];

También puede utilizar un objeto.

 ... let result = await response.json(); return { prop: result.prop, another: result.another, yetanother: 42 }
about 4 years ago · Juan Pablo Isaza Report
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!