BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
I need to get file contents into my app directly from a FileManager action. For example, when I double-click a file, I want to make an HTTP request to the FileService API to return the file content in the Body. I want to get the data as the result of the HTTP request (not treated as a downloaded by the browser).
Below is my attempt. Calling `getFile().subscribe(res => handleResponse(res)` activates the HTTP request, and the request gets made. The response body has the file content. But somehow the response creates a browser error, and I never get the data. I'd appreciate a hint on how to do this correctly. Thanks!
/** |
I figured out my own problem. For one, I was forming my HttpHeaders incorrectly; I needed to chain ".append()"s. However, the headers weren't the core of the problem.
The bigger issue is that I needed to customize Angular's `HttpClient.post()` with HttpOptions to instruct it to get just the response body text, and not try to parse it as JSON.
/** |
NOTE: There appears to be a bug in the Angular14 Typescript types for the `HttpClient.post()` method. The signature clearly accepts the body/text combination for the HttpOptions as shown above, but I couldn't get post() to work until I de-typed the HttpOptions object as `unknown`.
Hi Matthew,
Thank you for the suggestion. We are glad that the issue has been resolved. We are marking it as solved.
Regards,
Shereen