Last active
November 21, 2022 17:18
-
-
Save yakovenkodenis/b8137b9140db7a91851366d13c3ad4ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const api = { | |
auth: async (login, password) => { | |
await sleep(300); // simulate asynchronous call | |
if (login === 'admin' && password === 'secret') { | |
return { | |
token: crypto.randomBytes(20).toString('hex') | |
}; | |
} | |
return { | |
error: 'Unauthorized', | |
}; | |
}, | |
getUsers: () => { | |
return [ | |
{ login: 'johnny', email: '[email protected]' }, | |
{ login: 'valentine', email: '[email protected]' }, | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment