4

I was learning about Spring REST HATEOAS. But, I am confused about how we use it on the client end..

I mean, let's say I want write a client app using Angular JS. So now I don't have to hardcode the URL's to make REST API calls? And instead i'd use the "rel" attribute that gets returned?

for example, from angular JS,

  • I'd use the root URL "/products"
  • It returns links to individual products (Which I believe will be populated on UI)
  • User selects a product and angular will fetch the product details, along with relevant links to that product to delete, edit, etc..
  • If user clicks on delete, Angualar will use the URI specified in "rel=delete" to delete that product..

Is my understanding correct? Is there a sample angular code, that doesn't hardcode URI but use the rel attribute?

rakesh mehra
  • 618
  • 1
  • 9
  • 21
  • Well you can use any client side API and extract the links from the json as required or use a more specialised client library such as https://github.com/2muchcoffeecom/ngx-restangular – Alan Hay Nov 13 '19 at 19:09
  • 1
    Thanks! But, does client API get the URI based on 'rel=delete' attribute? If so, I assume the server side is expected to not change the 'rel' attribute as client will be hard coding it? – rakesh mehra Nov 14 '19 at 03:27

0 Answers0