0

I'm new to the hapijs. Can someone tell me what's the difference between POST and GET in hapijs? For some reason my POST method doesn't work at all so I do is INSERT via GET function.

GET:

server.route({
    method: 'GET',
    path: '/index/{orderId}',
    config: {
        handler: test,
        validate: {
            params: {
            orderId: Joi.string()
            .required()
            .description('Order indentifier')
            }
        }
    }
});

And test function:

function test (request, reply) {
  console.log(request.params.orderId);
  var params = {orderId: request.params.orderId}

  connection.query('INSERT QUERY HERE', function (err, res, fields) {
    if (err) throw error;
    console.log(res);
    reply(res);
  });
}
Shawn C.
  • 5,550
  • 2
  • 30
  • 37
Kali
  • 1
  • 2
  • Possible duplicate of [What is the difference between POST and GET?](http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get) – OldProgrammer May 01 '17 at 13:10
  • To improve the quality of your Question, please refer to what research you have done into this matter, and what about it was or was not helpful. Please include links to any sources you find particularly helpful. – toonice May 01 '17 at 13:29
  • Can you clarify what isn't working about the POST method? – Alex Robertson May 10 '17 at 14:52
  • For inserting something into database we need to use POST method, correct? But it doesn't work... So I'm using method GET to INSERT. Does it make sense? – Kali May 25 '17 at 11:54

0 Answers0