const {register,login,getAll,getByID,updateUser,deleteUser} = require("../dal/user.dal");
const userRegister = (data)=>{
let user = await register(data);
return user;
}
const loginUser = (data)=>{
let user = await login(data);
return user;
}
const userGetAll = async ()=>{
let users = getAll();
return users;
}
const userGetById = async (id)=> {
let user = await getByID(id);
return user;
}
const userUpdate =async (id,data)=>{
let user = await (id,data);
return user;
}
const userDelete = async (id)=> {
let user = await deleteUser(id);
return user;
}
module.exports = {userDelete,userGetAll,userGetById,userRegister,userUpdate,loginUser}
i need to solve this erros koa js passing errosi need to solve this erros koa js passing errosi need to solve this erros koa js passing errosi need to solve this erros koa js passing errosi need to solve this erros koa js passing errosi need to solve this erros koa js passing errosi need to solve this erros koa js passing errosi need to solve this erros koa js passing erros
CodePudding user response:
const {register,login,getAll,getByID,updateUser,deleteUser} = require("../dal/user.dal");
const userRegister = async (data)=>{
let user = await register(data);
return user;
}
const loginUser = async (data)=>{
let user = await login(data);
return user;
}
const userGetAll = async ()=>{
let users = await getAll();
return users;
}
const userGetById = async (id)=> {
let user = await getByID(id);
return user;
}
const userUpdate =async (id,data)=>{
let user = await updateUser(id,data);
return user;
}
const userDelete = async (id)=> {
let user = await deleteUser(id);
return user;
}
module.exports = {userDelete,userGetAll,userGetById,userRegister,userUpdate,loginUser}
CodePudding user response:
Use async in your first two functions. Await only works in Asynchronous Functions..
const userRegister = async (data)=>{
let user = await register(data);
return user;
}
const loginUser = (data)=>{
let user = await login(data);
return user;
}
CodePudding user response:
Except of the missing awaits, the above code does not really make sense, as you did not added any functionality. You are just encapsulating the given functions and instead calling your new functions, you can just call the original ones.