Node.js - Sending form data to hapi

Viewed 1180

I'm trying to send a variable from html form to hapi but i think i did somethings wrong.

addword.html :

    <form id="messages" action="/addword" method="POST">
  Your variable:
  <br>
  <input  type="text" name="your_variable" value="your_value">
  <br>
  <input type="submit" value="Submit">
</form>

server.coffee

server.route
    method: 'GET'
    path: '/addword'
    handler: (request, reply) ->
        reply.file './public/addword.html'  

###
ADD WORD
###

server.route 
  method: 'POST'
  path: '/addword'
  config: payload: output: 'data'
  handler: (request, response) ->
    your_variable = request.payload.your_variable
    console.log your_variable
    return

/server.js

/public/addword.html

what should i change to make it work?

0 Answers
Related