Search code examples
javascripthtmlformsexpressfacebook-messenger-bot

error 500 with express js routing after on form submit button clicked


I've been working on a messenger chatbot that recommends songs based on the mood of the user and I am stuck on routing a reply to the user after the HTML form for preferences has been filled out...

my HTML code only consists of a form that starts as: <form action="/postback" method="get">

in my index.js file, i check for the endpoint using: app.get('/postback', (req, res) => {

this always results in a 500 Internal Service Error in console. Would really appreciate some advice on why this may be happening.

EDIT: here are other relevant parts of my code:

const
  request = require('request'),
  express = require('express'),
  body_parser = require('body-parser'),
  path = require('path'),
  app = express().use(body_parser.json()); // creates express http server

here is an image of my file system: filepath


Solution

  • Change the method to POST. I do believe get doesnt send a request body. Forms should post data not get.