I want to map this response data coming from Woocommerce Rest API.
This is a snippet of the original Woocommerce Rest API response:
{
number: "206"
discount_tax: "0.00"
discount_total: "380.00"
meta_data {
0 {
id: 2928
key: "is_vat_exempt"
value: "no"
}
1 {
id: 2929
key: "att_info-94_1"
value: "||CJ||Cortez|| ||||84||"
}
2 {
id: 2930
key: "_alternate_phone"
value: "98765432"
}
}
}
And I want to transform it like this one.
{
number: "206"
discount_tax: "0.00"
discount_total: "380.00"
meta_data {
is_vat_exempt: "no"
att_info-94_1: "||CJ||Cortez|| ||||84||"
_alternate_phone: "98765432"
}
}
My Code:
public getFlightOrder() {
var params = {status:'completed',};
this.data_api.getflightOrder(params,this.passID.id)
.pipe(
map(responseData => {})
)
.subscribe((data) => {
this.bookingData = data;
}
);
}
As you can see there is no mapping yet as I don’t know where to start.
2
Answers
This question doesn’t really have anything to do with Angular 8 specifically but you can do something like this
EDIT
As per your question you can do the following
Try something like this: