Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consuming hateoas restful webservice with javascript (framework)

Is it possible to consume a hateoas type of restful webservice via (a) javascript (framework - e.g. angularjs)? I imagine that the client needs to implement quite a lot of logic to reach the actual endpoint. Any feedback would be very much appreciated. Thanks!

like image 389
cs0815 Avatar asked Oct 22 '22 07:10

cs0815


1 Answers

At least part of the issue here is that your API needs to return a media type that supports structured linking (which the usual "REST" API defaults application/json and application/xml do not). To get this support, checkout the HAL or JSONAPI projects.

With a structured linking definition, it becomes much easier to consume - HAL has several libraries to work with it, including a javascript library:

https://github.com/mikekelly/backbone.hal

For an interesting client, checkout the HAL Talk demo.

like image 163
papercowboy Avatar answered Oct 24 '22 04:10

papercowboy