let {
customer,
tool_type,
tool_brand,
tool_model,
tool_serial_code,
defect_type,
defect_description,
request_type,
request_description,
status
} = this
let payload = {
data: {
customer,
tool_type,
tool_brand,
tool_model,
tool_serial_code,
defect_type,
defect_description,
request_type,
request_description,
status
}
}
console.log(payload)
const payload = {
data: Object.fromEntries([
'раз свойство',
'два свойство',
'три свойство',
].map(n => [ n, this[n] ])),
};
const pickProps = (object, ...keys) => keys.reduce((acc, c) => ({ ...acc, [c]: object[c] }), {});
let payload = {
data: pickProps(
this,
'customer',
'tool_type',
'tool_brand',
'tool_model',
'tool_serial_code',
'defect_type',
'defect_description',
'request_type',
'request_description',
'status'
),
}