As I work on my code, I encounter the need to separate the key and value from a request params object in order to validate the value using ObjectID
. To achieve this, I decided to iterate over an array of entries and destructure the key and value for testing purposes. However, I am facing an error message:
'_key' is defined but never used
What steps should I take to resolve this issue?
export const validateObjectId = (request: Request, response: Response, next: NextFunction) => {
Object.entries(request.params).map(([_key, param]) => {
if (!ObjectId.isValid(param)) {
return errorConstants.sendErrorResponse(response, errorConstants.invalid_object_id);
}
});
next();
};