此代码:
req.reject({
name: 'Server returned error',
message: (`${message.errorcode}${message.data ? `, data: ${JSON.stringify(message.data)}` : ''}`)
});
产生带有不需要的\
字符的输出:
{
name: 'Server returned error',
message: 'Command failure, data: {"message":"No device with name \'aAASDASDA\' connected."}'
}
此代码:
req.reject({
name: 'Server returned error',
message: (`${message.errorcode}${message.data ? `, data: ${message.data}` : ''}`)
});
产生隐藏键和值的输出
{
name: 'Server returned error',
message: 'Command failure, data: [object Object]'
}
如何生成带有键和值但没有多余\
字符的输出
{
name: 'Server returned error',
message: 'Command failure, data: {"message":"No device with name 'aAASDASDA' connected."}'
}