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.
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 }