Skip to content

Instantly share code, notes, and snippets.

@jobelenus
Created May 13, 2019 21:11
Show Gist options
  • Save jobelenus/61d1eadf41c0fc88773f5dd8442fac22 to your computer and use it in GitHub Desktop.
Save jobelenus/61d1eadf41c0fc88773f5dd8442fac22 to your computer and use it in GitHub Desktop.
if (identityUser.mobile == participantNum) {
console.log('identity does exist')
const participantEntry = new SideChatParticipants(participant)
// eslint-disable-next-line no-return-await
try {
return await participantEntry.save()
} catch(err) {
console.log(err)
return false // or -1, or something you can check for your error condition, or even re-reaise `err`
}
})
// eslint-disable-next-line no-else-return
} else {
//if identity doesn't exist create in sql table and in dynamo table
console.log('identity doesnt exist')
let res = await rp.post({
uri: `http://${ROUTER_HOST}/identity-service/identity`,
body: newParticipant,
json: true
})
//creating an side chat participant in the dynamo db table
let participant.Id = res.id
const participantEntry = new SideChatParticipants(participant)
try {
return await participantEntry.save()
} catch (err) {
console.log(err)
return false // or -1, or something you can check for your error condition, or even re-reaise `err`
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment