zendesk/sunshine-conversations-javascript

TypeError: optional.includes is not a function

Closed this issue · 1 comments

gdo commented

#73 Hello, I use this code :

`
var jwt = require('jsonwebtoken')
var SmoochCore = require('smooch-core')

module.exports.init = (event, context, callback) => {
const appToken = jwt.sign({ scope: 'app' }, process.env.secret, { header: { kid: process.env.keyID}})

const smooch = new SmoochCore({
jwt: appToken
})

smooch.webhooks.create({
target: 'http://example.com/callback'
}).then((response) => {
.............
`

And when I execute it I have this exception :
TypeError: optional.includes is not a function
at /var/task/node_modules/smooch-core/lib/utils/smoochMethod.js:44:30
at Array.filter (native)
at WebhooksApi.create (/var/task/node_modules/smooch-core/lib/utils/smoochMethod.js:43:40)
at module.exports.init.smooch.webhooks.create.then (/var/task/init.js:14:19)

Could you tell me why ? I don't find my mistake.
I execute this code in an AWS lambda nodejs 4.2
with smootch-core 3.3.0

gdo commented

I find a solution :

include this code in your lambda

var includes = require('array-includes') 
delete Array.prototype.includes
includes.shim()