-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description / Steps to reproduce / Feature proposal
This is not an issue but rather a question, I did searched for possible answers with what I am trying to achieve but with no luck. I was trying to implement a simple route in the API that when a user visits the link, it will trigger a download action (PDF file) on their browser
I followed @loopback/example-shopping and managed to create a rest service running in Express similar to the example project. the rest service returns res.download(filePath) as response
Current Behavior
accessing the URL from loopback 4 controller opens the PDF viewer with empty content. But accessing the rest service directly (ExpressJS with res,download() as response) works fine
Expected Behavior
Similar behavior with ExpressJS res.download()
Hopefully someone can steer me to the right direction. Thank you!
EDIT:
I finally managed to make it work by injecting the RestBindings in the controller's constructor
constructor(
@inject(RestBindings.Http.RESPONSE) public response: Response,
) {}
we can then simply return this.response.download(filePath); in the route function.