I need to transfer API response to another component
The following code is from 'detail_item.component.ts', where data is sent to the route "bookitem" in 'book_item.component.ts'
onSubmit(){
this.appService.addItem(this.item).subscribe(item => {
if(item.status ==200){
this.router.navigate(['/bookitem'], {queryParams: {data: item.data}});
}
})
}
This code snippet is from 'book_item.component.ts'
ngOnInit() {
this.routeActive.queryParams.filter(params => params.data).subscribe(params => {
this.book_item = params.data;
});
}
After using console.log(this.book_item)
, the output is [object object] instead of expected JSON data.