Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

jwt.verify into promise mongoose with typescript

const verifyToken = <T>(token: string, secret: Secret): Promise<T> => {
	return new Promise((resolve, reject) => {
		jwt.verify(token, secret, (err, decode) => {
			if (!err) {
				resolve(decode as T);
			} else {
				reject(err);
			}
		});
	});
}
 
PREVIOUS NEXT
Tagged: #promise #mongoose #typescript
ADD COMMENT
Topic
Name
7+3 =