Skip to content

Commit

Permalink
fix(stark-core): add support for http 204 status code when persisting…
Browse files Browse the repository at this point in the history
… logs

As Stark does not use returned body when persisting logs, there is no need to force the backend
to send a 201 status code. The 204 status code should be accepted when no content is received.
  • Loading branch information
SuperITMan committed May 10, 2021
1 parent 99a0664 commit e24d92b
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ export class StarkLoggingServiceImpl implements StarkLoggingService {

const emitXhrResult = (xhrRequest: XMLHttpRequest): void => {
if (xhrRequest.readyState === XMLHttpRequest.DONE) {
if (xhrRequest.status === StarkHttpStatusCodes.HTTP_200_OK || xhrRequest.status === StarkHttpStatusCodes.HTTP_201_CREATED) {
httpRequest$.next();
httpRequest$.complete();
} else {
httpRequest$.error(xhrRequest.status);
switch (xhrRequest.status) {
case StarkHttpStatusCodes.HTTP_200_OK:
case StarkHttpStatusCodes.HTTP_201_CREATED:
case StarkHttpStatusCodes.HTTP_204_NO_CONTENT:
httpRequest$.next();
httpRequest$.complete();
break;
default:
httpRequest$.error(xhrRequest.status);
}
}
};
Expand Down

0 comments on commit e24d92b

Please sign in to comment.