How do I pass custom request headers (X-TRANSACTION-ID,X_USER_ID) in loopback for a POST API. We have the headers part in the data source file. But how do I make it dynamic ? I am using a remote method. Adding headers to the context object's request seems to make no difference. Only if the headers are added to the data source file , they seem to have an effect.
Passing Custom Request Headers in Loopback
Asked Answered
for the related model, within its .js file, you can use a beforeRemote hook to modify the request before executing the remote method.
the context object(ctx) have access to both request/response. E.g: you should be able to access the request body with ctx.req.body
© 2022 - 2024 — McMap. All rights reserved.