Passing Custom Request Headers in Loopback
Asked Answered
E

1

9

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.

Enunciate answered 22/6, 2015 at 18:48 Comment(0)
S
0

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

Sugared answered 20/11, 2017 at 22:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.