Reputation: 17
can you help me, i need to send a Center object in the body of the Get request and receive a WorkFlowDC object in return.
I don't know how I can write the method in the service file.
is there anyone who can help me solve this problem and thanks in advance.
findWorkflowDCByCentre(centre: Centre): WorkFlowDC {
if (this.jwtToken == null) { this.loadToken(); }
if (this.jwtHelper.isTokenExpired(this.jwtToken)) { this.addToken(); }
return this.httpClient.get<WorkFlowDC>(this.apiUrl + '/findWorkflowDCByCentre', centre,
{
headers: new HttpHeaders({ 'authorization': this.jwtToken })
}
);
}
Upvotes: 0
Views: 68
Reputation: 943999
The HTTP specification doesn't describe how GET requests with bodies should be handled so you shouldn't do this.
A payload within a GET request message has no defined semantics;
sending a payload body on a GET request might cause some existing
implementations to reject the request.
Browser APIs for making HTTP requests (fetch
and XMLHttpRequest
) don't support bodies on GET requests so you can't do this directly from Angular (you'd need to go through a server-side proxy).
Change the API so that it doesn't expect data in the body of a GET request.
Upvotes: 1