I was got single row of record into mysql via node and express js but returned result are this array inside object
output of result
[
{
"user_id": 1,
"name": "Aravinth",
"email": "anthu1510@gmail.com",
"password": "sha1$4bd1aa7a$1$21b6700d0949cfd187f41f8d05be550bc5b0e5a9",
"age": 27,
"city": "Coimbatore",
"status": "active",
"created_at": "2020-02-20T07:25:59.000Z",
"updated_at": "2020-02-20T07:25:59.000Z"
}
]
but i only want object code
{
"user_id": 1,
"name": "Aravinth",
"email": "anthu1510@gmail.com",
"password": "sha1$4bd1aa7a$1$21b6700d0949cfd187f41f8d05be550bc5b0e5a9",
"age": 27,
"city": "Coimbatore",
"status": "active",
"created_at": "2020-02-20T07:25:59.000Z",
"updated_at": "2020-02-20T07:25:59.000Z"
}
how to convert array inside single object to object
convert to array into object
let result = queryResult;
for (let index = 0; index < result.length; index++) {
let Obj = result[index];
console.log("Obj", Obj);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.