I'm trying to compress an image before making an http post call
this.activityService.addCourse(
course,
fileToUpload
).subscribe(
(result) => {
console.log(result);
this.handleSuccess('course_added_successfully');
},
error => {
this.handleError("an_error_occured");
}
);
And in the activityService.addCourse :
return this.imageService.compressImage(fileToUpload).map(result => {
if (fileToUpload) {
fileToUpload = result;
input.append("file", fileToUpload);
input.append("filetype_id", String(0));
}
if (typeof result.name !== 'undefined' && typeof result.size !== 'undefined' && typeof result.type !== 'undefined') {
this.http.post(Constants.URL_ADD_COURSE, input)
.map(FunctionsService.extractData).catch(FunctionsService.handleError);
}
else {
Observable.throw('Error compressing image');
}
});
When debugging i can see that the call arrives to this.http.post(Constants.URL_ADD_COURSE, input) and the returned value is successful, but the call is simply not being made (In Inspect element > Network i can see that nothing happened)