'Why are pipe() and subscribe() not firing after post() Angular 12
I am not getting any kind of follow-up on a post call in this function
upload(media: Media, data: Array<number>) {
let path: string = '';
if (media != null && media.id == null) {
path = `${this.restPrefix}/${this.appConfig.modIds.media}/upload`;
} else {
path = `${this.restPrefix}/${this.appConfig.modIds.media}/uploadAndReplace`;
}
const formData = new FormData();
const fileData = new Blob([new Uint8Array(data)]);
formData.append(
"file",
fileData,
'blank',
);
if (media.id != null) {
formData.append('id',media.id);
}
if (media.title != null) {
formData.append('title',media.title);
}
if (media.caption != null) {
formData.append('caption',media.caption);
}
return this.http.post<any>(
path,
formData,
{ headers: this.headersSrv.getMediaHeaders() })
.pipe(
tap((r) => {
if (this.debug) { console.log(`upload response ${r}`); }
}),
catchError(e => { return throwError(e); })
);
}
When I invoke the function
this.mediaSrv.upload(metadata, file).subscribe(
(r) => { console.log(r); input.responseText = r; },
(e) => {}
);
I don't see either the console.log message in the tap() or the follow-up .subscribe() as if neither are firing.
However, I can see in the Network tab that I do get a good response back. So, why isn't .subscribe() or .tap() working? Every other post call I have is running and logging debug messages.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
