Reputation: 3802
I have an Express REST API and want to destructure the Request
object. I use Typescript so I can see params
is of type Dictionary<string>
.
import { Request } from 'express';
export class UserService {
public deleteUserById = async ({ params }: Request): Promise<void> => {
const { id }: { id: number } = params;
};
}
I get an error
Property 'id' is missing in type 'Dictionary' but required in type '{ id: number; }'.
The body
for example is of type any
. But how can I destructure the params
object properly?
Upvotes: 0
Views: 987