I have a restful web service with the support of HATEOAS links. When I call \"http://localhost:8080/v1/bookings/1225380?lock=true\" link I got following resource URLs. I want t
You can create an Injectable for this and use this class instead of the angular http class. Here you filter the links and than call http with the right link.
@Injectable()
export class Hypermedia {
constructor(private http: Http) { }
get(links: any[], rel: String, body?: any, options?: RequestOptionsArgs): Observable<Response> {
var link = null;
var request = null;
// Find the right link
links.forEach(function (_link) {
if (_link.rel === rel) {
link = _link
return;
}
});
return this.http.get(link.href);
}
}
Provide this injector and add it to the constructor where you need it
constructor(private hypermedia:Hypermedia)
Then you can simply call it like you normally would call the http class
this.hypermedia.get(myHypermediaLinksArray,myRel)
Hope this helps:)