0

我有以下电话:

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

和以下路线:

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

})

我正在尝试在“//get hello”上获取名为“hello”的参数。我曾尝试使用“req.params”,但它返回 {}。

调用有什么问题或者我怎样才能得到 hello 参数?提前致谢

4

1 回答 1

-1

看样子,你用的是快递,不是吗?

尝试:

server.route({
    path: '/api/hello',
    method: 'GET',
    handler(req, reply) {
        let hello = req.query.hello; // here
    }
})
于 2018-06-07T14:02:40.020 回答