Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Data must be a string or a buffer #21

Closed
EkiFauziFirdaus opened this issue Apr 20, 2017 · 2 comments
Closed

TypeError: Data must be a string or a buffer #21

EkiFauziFirdaus opened this issue Apr 20, 2017 · 2 comments

Comments

@EkiFauziFirdaus
Copy link

I got error:

TypeError: Data must be a string or a buffer
    at TypeError (native)
    at Hmac.Hash.update (crypto.js:74:16)
    at LineBot.verify (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\linebot\lib\linebot.js:30:5)
    at parser (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\linebot\lib\linebot.js:149:38)
    at jsonParser (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\body-parser\lib\types\json.js:103:7)
    at C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\linebot\lib\linebot.js:148:4
    at Layer.handle [as handle_request] (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\GitRepo\Warframe-Alert-BOT-LINE\node_modules\express\lib\router\layer.js:95:5)

I'm using linebot v1.3.0...
My code:

const express = require('express');
const app = express();
const linebot = require('linebot');
var bot = linebot({
	channelId: '15xxxxxxxx',
	channelSecret: '16f6862afec3d23b0ee02exxxxxxxxxx',
	channelAccessToken: '6x57DzbyGaSMEj9S4hTfhYsJERvwothosBwAoEJTwDqLuOncgvaWShD59OLpYFf9WdIZlgga5XjnyrTHIVPjLNGaHi7V0H4wGpI9w/0IyEjQtFmBVo74fCNjTiuwwSNAqZNa9fNlVaiRk5zTBsNaNAdB04t89/1O/xxxxxxxxxx=',
	verify: true
});

const linebotParser = bot.parser();
app.get('/linewebhook', linebotParser);
app.get('/test', function(req, res) {
  res.json({notes: "Hello"})
})
app.listen(3000);
@boybundit
Copy link
Owner

boybundit commented Apr 20, 2017

@EkiFauziFirdaus LINE webhook URL is called via POST method instead of GET.

app.post('/linewebhook', linebotParser);`

Also, it assumes that the request body has never been parsed by any body parser before, so it must be placed BEFORE any generic body parser, if there is any.

app.post('/linewebhook', linebotParser);
app.use(bodyParser.json());

@EkiFauziFirdaus
Copy link
Author

EkiFauziFirdaus commented Apr 20, 2017

My bad... I'm sorry...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants