I have a test wordpress blog set up. To enhance the functionality, I developed an angular app that utilizes the wordpress rest api. The app makes a call to an endpoint to retrieve categories. However, the JSON response contains unnecessary data for my application. As a solution, I created a model with specific values such as name and slug. Yet, when I log the response to the console, it still shows all the data. How can I limit this?
Code:
model
export interface BlogCategoryModel {
id: number;
name: string;
slug: string;
parent: number;
}
service
getCategories(): Observable<BlogCategoryModel[]> {
const url = 'https://blog.varanjith.com/wp-json/wp/v2/categories';
return this.http.get<BlogCategoryModel[]>(url);
}
component
ngOnInit() {
this.blogService.getCategories().subscribe((x: BlogCategoryModel[]) => {
console.log(x);
});
}
output
https://i.sstatic.net/hUxsj.png
Why am I seeing count and description in the console output? What could be causing this issue? I did not include count and description in the BlogCategoryModel.