const sendData = result => {
result.centers.forEach(center => {
const data = {
center_id,
name,
address,
district_name,
state_name,
pincode,
fee_type,
sessions
} = center ;
data.sessions = data.sessions.map(session => {
return {
date,
available_capacity,
min_age_limit,
vaccine
} = session ;
})
console.log(data) ;
})
}
为什么上面的代码会产生以下错误?
PS:请忽略行号。
UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.
at /home/ubuntu/Projects/Web/CowinTracker/server/app.js:69:17
at Array.map (<anonymous>)
at /home/ubuntu/Projects/Web/CowinTracker/server/app.js:67:39
at Array.forEach (<anonymous>)
at sendData (/home/ubuntu/Projects/Web/CowinTracker/server/app.js:56:20)
我尝试更改const data
为let data
并发生相同的错误。