I'm writing some Nodejs services with Typescript. For some reason, it return me the same error message: Services.ts:43:1 - error TS1005: ')' expected.
this is the code:
function Register (user: UserAttribute):Promise<void>{
return Users.find(user.email).then(userexist => {
if (!userexist) {
throw new Error('Usuario no encontrado. Por favor registrar Usuario')
}
}).then(user, (UserExist) => {
bycript.compareSync({user:user.password}, userexist)
}).then( password => {
if (password) {
return password
}else{
throw new Error('Contraseña no es correcta')
}
}).catch((error) => {
throw new Error(error)
}).then(() => {
Users.create({
first_name: user.first_name,
last_name: user.last_name,
email: user.email.toLowerCase(),
password: ismatch
}).then((id,email) => {
jwt.sign({id: user.id?.toString(), name: user.name}, TOKEN_SECRET)
}).then((token, user) => {
return {first_name: user.first_name, last_name:user.last_name, email:user.email, token: user.token};
}).catch((error) => {
return('Usuario no pudo ser creado', error)
})
},
function Login(user:UserAttribute):Promise<void> {
return Users.find(user.id, user.password).then((response) => {
return({response: 'Nombre y email correctos. Puede acceder!'})
})
},
module.export = {Login, Register}
By due way, the 43 line found afer module.export
(which is the line 42)
If anyone could bring me some help; i'd really be grateful.
Thanks and have a nice day!
You are not closing a parentheses before userCreate
.then(() => {
Users.create({
first_name: user.first_name,
last_name: user.last_name,
email: user.email.toLowerCase(),
password: ismatch
}).then((id,email) => {
jwt.sign({id: user.id?.toString(), name: user.name}, TOKEN_SECRET)
}).then((token, user) => {
return {first_name: user.first_name, last_name:user.last_name, email:user.email, token: user.token};
}).catch((error) => {
return('Usuario no pudo ser creado', error)
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.