0

I have the following call:

      $http.get(
    '../api/hello', {
      params: {
        hello: "world"
      }
    }).then(function (res) {
      //do response
    })

and the following route:

    server.route({
    path: '/api/hello',
    method: 'GET',
    handler(req, reply) {
        //get hello
    }

})

I'm trying to get the parameter called 'hello' on the '//get hello'. I have tried to use 'req.params' but it returns {}.

Is there something wrong with the call or how can i get the hello parameter? Thanks in advance

Sneijky
  • 11
  • 2
  • What framework are you using? – Justinas Jun 07 '18 at 14:00
  • I would suggest inspecting your requests in the network tab of your browser devtools to make sure that your parameters are being sent to the server. you can check this [link](https://developers.google.com/web/tools/chrome-devtools/network-performance/reference) for refference – Osvaldo Maria Jun 07 '18 at 14:07

1 Answers1

-1

Form look of it, you are using express, aren't you?

Try:

server.route({
    path: '/api/hello',
    method: 'GET',
    handler(req, reply) {
        let hello = req.query.hello; // here
    }
})
WuDo
  • 195
  • 8