Skip to content

Wrong api service generation #651

@RomainSanchez

Description

@RomainSanchez

What type of issue are you creating?

  • [ x] Bug
  • Enhancement
  • Question

What version of this module are you using?

  • 2.0.10 (Stable)
  • 2.1.0-rc.n (2.1 Release Candidate n)
  • [ x] 2.3.1

Hi when generating the service for a model, the typescript function does not post the request data.

here is my model remote method config:

"methods": {
    "upload": {
      "http": [
        {
          "path": "/upload",
          "verb": "post"
        }
      ],
      "accepts": [
        {
          "arg": "req",
          "type": "object",
          "required": true,
          "http": {
            "source": "req"
          },
          "description": "The http request"
        }
      ],
      "returns": [{
        "arg": "response",
        "type": "string",
          "required": true,
        "description": "The http response"
      }],
      "description": "Upload a file"
    }
  }

And here is the generated function :

 public upload(req: any, customHeaders?: Function): Observable<any> {
    let _method: string = "POST";
    let _url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() +
    "/Attachments/upload";
    let _routeParams: any = {};
    let _postBody: any = {};
    let _urlParams: any = {};
    let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders);
    return result;
  }

The _postBody is empty, the req parameter is not used.

In older versions it used to be let _postBody = {data: req}

Metadata

Metadata

Assignees

No one assigned

    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