Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Jeyasingh Yovan
2.2k
3
539
Declare array of objects
Aug 23 2020 6:21 AM
I need to store array of objects and then convert that into string using JSON.stringify and transfer that string to external link. Below is my typescript code..
let orderItems: any[] = [];
let order_data = {};
this.storage.get("cart").then((cart) => {
cart.forEach((element, index) => {
orderItems.push({ "product_id": element.product.id, "quantity": element.qty });
});
});
console.log(orderItems);
order_data = {
"customer_name": "Singh",
"line_items": orderItems,
}
console.log(JSON.stringify(order_data));
In my console I got empty array of objects..... {"customer_name":"Singh","line_items":[]}
Anyone here pls help me out of this... Thank you in advance....
Reply
Answers (
2
)
How to replace empty space with underscore in typescript
Filter the json object