Skip to content

RestBindings.Http.Request.query property always 'undefined' #2088

@larsm11

Description

@larsm11

I have been using LB4 since July, and until recently I've been able to grab the query parameters from the RestBindings.Http.Request.query using the following injection statement in my controller constructor

@inject(RestBindings.Http.REQUEST) private req: Request,

Followed by this.req.query.<property> somewhere in my code.

This no longer works, even if I create a brand new application using the latest lb4 app and try to expose the query via the default Ping-controller. When trying the following section of code

      query: 'Query response: ' + this.req.query.start,
      greeting: 'Hello from LoopBack',
      date: new Date(),
      url: this.req.url,
      headers: Object.assign({}, this.req.headers),

using this request localhost:3000/ping?start=2018-08-25&end=2018-09-09&user=larsm
reponse now returns 'undefined' (rather than returning the query parameters):

{
  "query": "Query response: undefined",
  "greeting": "Hello from LoopBack",
  "date": "2018-11-27T23:21:53.142Z",
  "url": "/ping?start=2018-08-25&end=2018-09-09&user=larsm",
  "headers": {
    "host": "localhost:3000",
    "connection": "keep-alive",
    "cache-control": "max-age=0",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36",
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "accept-encoding": "gzip, deflate, br",
    "accept-language": "nb-NO,nb;q=0.9,en-GB;q=0.8,en;q=0.7,no;q=0.6,nn;q=0.5,en-US;q=0.4"
  }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions