Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated functions doesn't work with post data anymore #367

Closed
Undrium opened this issue Feb 27, 2017 · 3 comments · Fixed by #387
Closed

Generated functions doesn't work with post data anymore #367

Undrium opened this issue Feb 27, 2017 · 3 comments · Fixed by #387
Assignees
Milestone

Comments

@Undrium
Copy link

Undrium commented Feb 27, 2017

House.remoteMethod('getRandomHouse', {
        accepts: [{ arg: 'profile', type: 'object', http: { source: 'body'}}],
        returns: {root: true},
        http: {path: '/random', verb: 'POST'}
  });

generates:

public getRandomHouse(profile: any = {}): Observable<any> {
    let _method: string = "POST";
    let _url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() +
    "/houses/random";
    let _routeParams: any = {
      profile: profile
    };
    let _postBody: any = {};
    let _urlParams: any = {};
    let result = this.request(_method, _url, _routeParams, _urlParams, _postBody);
    return result;
  }

Shouldn't the postBody have the profile?

@barocsi
Copy link

barocsi commented Feb 27, 2017

Turns out I ran in the same bug right now. But hey, bright side: solved, kind of!

in index.js 718 row

  function paramIsRoute(param) {
    return (param.http && param.http.source === 'path') || (param.arg && param.arg.match(/(^id$|fk|file|container)/));
  }

therefore ANY path you provide contains file (aka: profile) will be put in the route.
👍 funny! Just rename your argument names

@Undrium
Copy link
Author

Undrium commented Feb 27, 2017

Hehe, cheers and thanks! We should provide a fix to this in the future however.

@jonathan-casarrubias
Copy link
Collaborator

Ha too bad, pro'file' I see.

I will change that regex asap.

Cheers
Jon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants