I am sending a GET request from my Angular client to the Java Vertx server where I am doing some operation on the server. Now at the end of the operation on the server, I send a message to the client notifying it that the operation has finished. But for some reason the API stays in the 204 and does not return 200 OK in the Network tab of the browser. But in the console I get to see the string which I send to the client. Please see image to clarify things.
Component class
startPrint(id: string) {
console.log('Insdie startPrint() ::: JobID ',id);
let jobStatus = this.job_status.get(Number(id));
this.toggle(jobStatus, Number(id));
if(jobStatus =='START')
{
console.log('INSIDE IF!!');
this.coreService.getJobSerialToPrint(id).subscribe(
(next) => {
console.log("response in startPrint: " + JSON.stringify(next));
console.log("response in startPrint: "+ next);
},
(err) => {
console.log("error in response in startPrint: " + err);
}
);
}
else{
console.log('INSIDE ELSE ---- Need to Pause Job on server');
}
}
Service class
//Start printing label for Job
getJobSerialToPrint(id: string) {
console.log("Send start print command to server!!: ", id);
return this.httpClient.get(environment.restUrl + "/jobserials/"+id);
}
Vertx code
startPrintJob(jobID, context)
.onFailure(error -> {
LOG.debug("startTest() Failed: ", error);
})
.onSuccess(res -> {
LOG.debug("Finished !!");
LOG.debug(" onSuccess for startPrintJob() " + res);
String updatedStatus = "Job finished printing "+jobID;
context.response().setStatusCode(HttpResponseStatus.OK.code())
.putHeader(HttpHeaders.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
.end(new JsonObject().put("message", updatedStatus)
.put("path", context.normalizedPath()).toBuffer()
);
})
console image