Open thejasvi-ks opened 5 years ago
I'm getting the below error while trying to authenticate the user. I have searched for the solutions and changed the code according to that but nothing seems to be working. A quick help would be much appreciated.
And here is my code,
const express = require('express') const bodyParser = require('body-parser') const cors = require('cors') const Chatkit = require('@pusher/chatkit-server')
const app = express()
const chatkit = new Chatkit.default({
instanceLocator: 'Pusher Locator Key', key:'Pusher Secret Key'
})
app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.json()) app.use(cors())
app.post('/users', ( req, res ) => {
const { username } = req.body
chatkit.createUser({ name: username, id: username }) .then(() => res.sendStatus(201)) .catch(error => { if(error.error_type === 'services/chatkit/user_already_exists'){ res.sendStatus(200) } else{ res.status(error.statusCode).json(error) } }) })
app.post('/authenticate', ( req, res ) => {
const { grant_type } = req.body res.json(chatkit.authenticate({ grant_type, userId : req.query.user_id }))
const PORT = 3001 app.listen(PORT, err => { if (err) { console.error(err) } else { console.log(Running on port ${PORT}) } })
Running on port ${PORT}
Thanks in advance..!
I'm getting the same error, any luck?
Hello, guys, has anyone found a fix, I have been searching for days please help??? @dhairyadwivedi @thejasvi-ks
Solved !! [Fix] Try restarting your emulator.
I'm getting the below error while trying to authenticate the user. I have searched for the solutions and changed the code according to that but nothing seems to be working. A quick help would be much appreciated.
And here is my code,
const express = require('express') const bodyParser = require('body-parser') const cors = require('cors') const Chatkit = require('@pusher/chatkit-server')
const app = express()
const chatkit = new Chatkit.default({
instanceLocator: 'Pusher Locator Key', key:'Pusher Secret Key'
})
app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.json()) app.use(cors())
app.post('/users', ( req, res ) => {
const { username } = req.body
chatkit.createUser({ name: username, id: username }) .then(() => res.sendStatus(201)) .catch(error => { if(error.error_type === 'services/chatkit/user_already_exists'){ res.sendStatus(200) } else{ res.status(error.statusCode).json(error) } }) })
app.post('/authenticate', ( req, res ) => {
const { grant_type } = req.body res.json(chatkit.authenticate({ grant_type, userId : req.query.user_id }))
})
const PORT = 3001 app.listen(PORT, err => { if (err) { console.error(err) } else { console.log(
Running on port ${PORT}
) } })Thanks in advance..!