-2

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

3 Answers3

1

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.

Sebastian Hildebrandt
  • 2,661
  • 1
  • 14
  • 20
0

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}
yatender
  • 3
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 30 '22 at 13:08
0

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;
}
sms
  • 1,380
  • 1
  • 3
  • 5