I am working on expressJS app and I need to send post request to url. I am using sequelize and get datas from mssql database table. My datas coming like [ { "x":"data1", "y":"data2", "z":1, "w":3 } ]
In the api documentation, I must post data just like { "x":"data1", "y":"data2", "z":1, "w":3 }
this type.
I don't know how can I convert? What are differences of both type?
Thanks for your help
[{ x: "data1", y: "data2", z: 1, w: 3 }]
Above snippet is an array. You want to convert it into object. So you can use array index to get data ie object
from an array.
const array = [{ x: "data1", y: "data2", z: 1, w: 3 }]; const obj = array[0]; console.log(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.