javascript - How to consume a HATEOAS REST API in Angular? -


i'm working on angular 4 front-end api built team. api follows hateoas , provides me hypermedia links every single response.

i know shape of api , figure can hard-code urls angular services minimal fuss. however, colleague (who backend developer) trying convince me should take full advantage of hypermedia because mean less coupling between frontend , backend (and potential breakage if api changes).

however, i'm stumped on how i'd go implementing simple hateoas pattern using angular's built-in http service. how store/share hypermedia/url information in way doesn't couple services , make them hard-to-test? there seems no examples out there.

would trying create hateoas-friendly http client idea, or not worth trouble?

your colleague right, should use meta information back-end provides. in way not putting responsibility on client doesn't belong there. why should client know fetch entities? storing entities (in fact data in general) responsibility of back-end. back-end owns data, decides put it, how access it, when change location or persistence type, related storing data.

how store/share hypermedia/url information in way doesn't couple services , make them hard-to-test?

why think using hateoas makes testing harder? not, in fact not using makes testing harder urls static makes back-end non-stub-able.

you can extract information back-end response , store meta-information in angular model, on _meta key or that.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -