Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Why won't Angular retrieve foreign keys in a get request to the backend?

 
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have a User class and a Company class in Java.  When I use the user service in Angular to get the user details, it gets everything, but the Company is part of the user as a foreign key, but that keeps coming back undefined.   Is there a way to do this?  

Here is what I've been doing.  



When I try user.company, it comes back as undefined.


This is my user service function.




I'm subscribing to it properly and it is getting the details, but just not the company.
 
Nathan Milota
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I can't find anywhere on the internet how to solve this problem.  
 
Marshal
Posts: 3457
493
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Is this really an Angular issue?  If you use a tool like Postman or curl to query the backend, do you see the same behaviour?
 
Nathan Milota
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Ron McLeod wrote:Is this really an Angular issue?  If you use a tool like Postman or curl to query the backend, do you see the same behaviour?



I can't see the company information on Postman either, because on the back end Spring Data JPA, I have a @JsonBackReference annotation.   Without that or @JsonIgnore, it throws an infinite loop and crashes the program.   I don't know what else to do.
 
Nathan Milota
Ranch Hand
Posts: 442
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator





Those are my User and Company classes in Java.
 
Ron McLeod
Marshal
Posts: 3457
493
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
No point is discussing the same issue in two different threads; besides, it seems clear that this is not an Angular issue.

Continued here: @JsonIgnore is stopping me from getting and posting foreign keys, but program crashes without it.
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
    Bookmark Topic Watch Topic
  • New Topic