Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created July 21, 2019 16:48
Show Gist options
  • Select an option

  • Save jsmanifest/c73a8301826a28b797a28dbd8e293a33 to your computer and use it in GitHub Desktop.

Select an option

Save jsmanifest/c73a8301826a28b797a28dbd8e293a33 to your computer and use it in GitHub Desktop.
function createAccount(
username = '',
password = '',
nickname = '',
email = '',
gender = 'Male',
bio = '',
subscription = 'Basic',
callback,
) {
if (!username || !password || !email) {
throw new Error(
'You are missing one or all of the following fields: "username", "password", "email"',
)
}
return api
.createAccount({
username,
password,
nickname,
email,
gender,
bio,
subscription,
})
.then((result) => {
if (callback) callback(null, result)
})
.catch((error) => {
console.error(error)
if (callback) callback(error)
})
}
createAccount(
'lucas',
'applebee123x123',
'',
'[email protected]',
'',
'My bio',
'Basic',
function cb(err, data) {
if (err) {
console.error(err)
}
// do something with data
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment