Created
July 17, 2020 21:47
-
-
Save isaidspaghetti/1eebf1a62534d5970a2c6b5ffaeb2c82 to your computer and use it in GitHub Desktop.
backend router handler
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
//backend/routes/index.js:46 | |
router.post('/registrations', async (req, res, next) => { | |
try { | |
await createHubspotContact(firstName, lastName) | |
const client = new StreamChat.StreamChat(apiKey, apiSecret); | |
[customer, supporter] = createUsers(firstName, lastName) | |
await client.upsertUsers([ | |
customer, | |
supporter | |
]); | |
const channel = client.channel('messaging', customer.id, { | |
members: [customer.id, supporter.id], | |
}); | |
const customerToken = client.createToken(customer.id); | |
res.status(200).json({ | |
customerId: customer.id, | |
customerToken, | |
channelId: channel.id, | |
apiKey, | |
}); | |
} catch (err) { | |
console.error(err); | |
res.status(500).json({ error: err.message }); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment