I have an app developed using ionic 2, is about quotes. I want to manage the quotes (and authors, categories, etc) with Wordpress and his REST API. At first instance i used normal posts, but now i am trying with custom post types, becouse that gives me more control and organization in the backend, so i have one CPT for quotes
and other for authors
, and a relation between them.
Example ↓
wp-json/wp/v2/quotes
[
{
id: 79,
x_metadata: {
custom_post_type_onomies_relationship: "77",
quote: "Be yourself; everyone else is already taken"
}
}
]
wp-json/wp/v2/authors
[
{
id: 77,
title: {
rendered: "Oscar Wilde"
},
x_metadata: {
bio: "https://wikipedia.org/wiki/Oscar_Wilde"
}
}
]
Like you can see, the relation is in custom_post_type_onomies_relationship
, but i don't know how to merge this data properly in the app (in which i use Angular 2/Typescript).
The only way i can think is loop through the quotes, for every quote loop through authors checking ids, and then add the data from the author inside the quotes array. Is that okey or is there any other way more efficient?
Thanks in advance and sorry if my english is not perfect.