Looking at the function below, I aim to map _s from res to another function using the return value from the manipulateValidateReqRes function
CODE WAS UPDATED BELOW
Why am I unable to return _s from the map function on res? It displays an error: TypeError: Object has no member 'map'
UPDATE
To provide a clear explanation and update the debugging process, here is my latest code snippet
const res = {
"valid_data": [
{
"shipper_name": "automate sender1",
"rts_reasons": [
"a reason"
],
"rts_score": 0
},
{
"shipper_name": "automate sender2",
"rts_reasons": [
"a reason"
],
"rts_score": 0
}
],
"shipping_rates": [
{
"reguler": {
"summary_price": "7.000",
"data": [
{
"_s": "9917xxx",
}
]
},
"express": {
"summary_price": "15.000",
"data": [
{
"_s": "9918xxx"
}
]
}
}
],
"errors": [
[],
[]
]
}
const manipulateRequest = Object.values(res).map((obj) => {
return {
shipper_name: res.valid_data[0].shipper_name
}
})
const postBulkPayload = {
"filename": "filename1.xlsx",
"total_order": manipulateRequest.length,
"is_use_new_payment": true,
"template_name": "bulk-order-with-postal_code-and-sub_district_name",
"details": manipulateRequest,
"cancelToken": {
"promise": {}
}
}
console.log(postBulkPayload)
The result shows:
{
filename: 'filename1.xlsx',
total_order: 3,
is_use_new_payment: true,
template_name: 'bulk-order-with-postal_code-and-sub_district_name',
details: [
{ shipper_name: 'automate sender1' },
{ shipper_name: 'automate sender2' },
{ shipper_name: 'automate sender1' }
],
cancelToken: { promise: {} }
}
Why isn't 'automate sender2' being printed?