I have a get request in a component that returns a response
getPaymentIntents():Observable<Payment>>{
const url: string = 'https://store.com//payments';
return this.http.get<Payment>>
(url);
}
The response data looks something like this (the “Payment” type)
[
{
"id": "pi_3K4B432423dqM1gTYncsL",
"amount": 2000,
"amount_capturable": 0,
"amount_received": 0,
"application": null,
"canceled_at": null,
"cancellation_reason": null,
"created": 1638911287,
"currency": "usd",
"customer": "cus_KjDBkdsaHIT6AN"
},
{
"id": "pi_3K4BW7EE9YQoA1qM1gTYncsL",
"amount": 1000,
"amount_capturable": 0,
"amount_received": 0,
"application": null,
"canceled_at": null,
"cancellation_reason": null,
"created": 1638913687,
"currency": "usd",
"customer": "cus_KjDBkxEVHIT6AN"
}
]
I want this data to be in a “Material Table” https://material.angular.io/components/table/overview
But I only want it to display a subset of the data. (In the future I will want to combine another response’s data into the table as well)
The type I want to pass to the table as a dataSource
is this
export interface OrderToProcess{
Id: string,
Amount: number,
Currency: string
}
How do I go about converting one type into the other, I’ve tried filter()
map()
object.entries()
and I’m sure I’m not using them right but none seem to do what I am after.
Thanks for any help!