Here is a snippet of my code
const data = [ ...prev, ...resp.data ]
This crashes if resp.data
is not defined. With the new chaining operator syntax I have found following solution how to handle the case that resp.data
is undefined
.
const data = [ ...prev, ...( resp?.data || [] ) ]
It works fine. I just wonder if there is some shorter syntax.