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
}
}));