Front-end Table Script Error

I have a front-end script that's filtering some JSON objects, displaying only a few key properties, using a map() call. The script works fine, but I'm getting an error every time it executes.
No description
No description
7 Replies
rubenf
rubenf11mo ago
The error is that bg_0.result is undefined
Trevor Sullivan
Trevor Sullivan11mo ago
But it's not undefined ... it's working properly
Trevor Sullivan
Trevor Sullivan11mo ago
My items are populated in the result
No description
Trevor Sullivan
Trevor Sullivan11mo ago
Oh wait ... maybe it's undefined initially, but after bg_0 completes, it calls it again
rubenf
rubenf11mo ago
Could you share a minimal reproduction of your app please
Trevor Sullivan
Trevor Sullivan11mo ago
Yup ... this is what was happening. I wrapped the result in an if statement.
if (bg_0.result != undefined) {
return bg_0.result.map(val => {
return {
name: val.name,
type: val.type,
status: val.status
}
})
}
else {
return []
}
if (bg_0.result != undefined) {
return bg_0.result.map(val => {
return {
name: val.name,
type: val.type,
status: val.status
}
})
}
else {
return []
}
rubenf
rubenf11mo ago
you can also add ? in a few places bg_0.result?.map .... ?? []
Want results from more Discord servers?
Add your server
More Posts