I get undefined using this code:
const json = {"records":[{"recordid":"1694119","recordindex":1,"status":"updated successfully"}],"message":{"returncode":1}};
const { records: {status} } = json;
console.log(status);
How to get the expected: "updated successfully"?
Since records
is an array, you need to add brackets:
const json = {"records":[{"recordid":"1694119","recordindex":1,"status":"updated successfully"}],"message":{"returncode":1}};
const { records: [{status}] } = json;
console.log(status);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments