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

141
Vistas
Is there any ways to make this code shorter to return object?

I want to make this code shorter.

 const coupons = rets.map((ret) => ({
  coupon_id: ret.coupon_id,
  bot_id: ret.bot_id,
  lang_cd: ret.lang_cd,
  coupon_name: ret.coupon_name,
  start_date: ret.start_date,
  end_date: ret.end_date,
  coupon_data: ret.coupon_data,
  title: ret.title,
  sub_title: ret.sub_title,
  image: ret.image,
  style: ret.style,
  section: ret.section,
  button_pc: ret.button_pc,
}));

I get rets from DB.

I tried like below by myself but it didn't work well. error says like [column is string].

const couponColumns = [
  'coupon_id', 'bot_id', 'lang_cd', 'coupon_name', 'start_date', 'end_date', 
  'coupon_data', 'title', 'sub_title',' image', 'style', 'section', 'button_pc'
]

const coupons = rets.map((ret) => ({
   couponColumns.map((column) => {
     column: ret.column
   }
}));
about 4 years ago · Juan Pablo Isaza
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