-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
| const payload = { |
Here what you're doing is taking two arguments then put them into a single object, which is when it makes sense to take that object from the beginning as one parameter
const createCookie = (otps) => {
const token = sign(opts, process.env.SECRET);
return token;
};we can do validation here like
const createCookie = (otps) => {
if (!opts.userId) throw new Error('missing user id in cookie input') // or whatever error message you feel makes sense to you
const token = sign(opts, process.env.SECRET);
return token;
};validation is always good, in your original function, you could forget to enter a value and the function will not tell you anything.
NouraldinS
Metadata
Metadata
Assignees
Labels
No labels