Type for Request object #1084
-
I have a case where i need to pass the ctx.request object to a function. But I am not able to find an exposed Request type/interface inside foalts. Request is defined in core/http/context.d.ts, but not exported. As an alternative I tried using Request interface from @types/express. But typescript is throwing incompatibility error. Can someone pls suggest me how to use type for Request object? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @text2n 👋 Can it work if you define a type Request = Context['request'] |
Beta Was this translation helpful? Give feedback.
-
@LoicPoullain The issue is when we have a function which accepts request as parameter. For example, the below hypothetical function accepts request object (req) as parameter. if we are using typescript, to define the type of "req" we need access to Request interface. I am sorry if i am missing something. I am bit new to typescript.
|
Beta Was this translation helpful? Give feedback.
Hi @text2n 👋
Can it work if you define a
Request
type like this in your code?