Following is my server side code :
processRequest.process(selectedDiaryVersion, modality, operation)
.then(function(uniqueName){
console.log("before sending success response in /code");
console.log("name of the zip file is : " + uniqueName);
return res.status(200).json({
message : 'success in building code zip',
obj : uniqueName
});
})
.catch(function(){
console.log("before sending error response in /code");
return res.status(404).json({
title: 'An error occurred',
error : { message : 'Error in building code zip'}
});
});
After my processRequest.process promise returns I see the following in my console.log -> "before sending success response in /code". But when my res.status(200).json({}) returns to the client, I see the following error: "Failed to load resource: net::ERR_EMPTY_RESPONSE".
The following is my angular 2 code in client side:
getCodeZip(selectDiaryVersion ) {
const body = selectDiaryVersion;
const headers = new Headers({'Content-Type': 'application/json'});
//noinspection TypeScriptValidateTypes
return this._http.post('http://localhost:1000/build/code?modality='+this.modailityPicked, body, {headers: headers})
.map(response => {
console.log("Inside success code zip");
const data = response.json().obj;
console.log(data);
return data;
})
.catch(error => {
console.log("Inside error in service -> getCodeZip()");
console.log("Error is " + error);
return Observable.throw(error.json());
});
}
And I see this printed as well on the client side "Inside error in service -> getCodeZip()". I also see this in the error response on the client side:
Response with status: 0 for URL: null. Then error.ProgressEvent shows this: ProgressEvent bubbles : false cancelBubble : false cancelable : false composed : false currentTarget : XMLHttpRequest defaultPrevented : false eventPhase : 2 isTrusted : true lengthComputable : false loaded : 0 path : Array[0] returnValue : true srcElement : XMLHttpRequest target : XMLHttpRequest timeStamp : 258010.36500000005 total : 0 type : "error"
How do I solve the net::ERR_EMPTY_RESPONSE issue? Is it because my server response is taking too long?