Skip to content

Instantly share code, notes, and snippets.

@yakovenkodenis
Last active November 21, 2022 17:18
Show Gist options
  • Save yakovenkodenis/b8137b9140db7a91851366d13c3ad4ba to your computer and use it in GitHub Desktop.
Save yakovenkodenis/b8137b9140db7a91851366d13c3ad4ba to your computer and use it in GitHub Desktop.
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: 'johnny@example.org' },
{ login: 'valentine', email: 'valentine@example.org' },
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment