TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Jeyasingh Yovan
NA
3
710
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