Skip to content

Commit

Permalink
add query to remote
Browse files Browse the repository at this point in the history
  • Loading branch information
sguilly committed Jun 11, 2018
1 parent 776b226 commit 610bf9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ loopbackClientWithAuth.createToken()

remote(customRoute,data) -> your customRoute name (example: greet) see https://loopback.io/doc/en/lb3/Remote-methods.html

remote(customRoute,query,data) -> your customRoute name (example: greet) see https://loopback.io/doc/en/lb3/Remote-methods.html




Expand Down
6 changes: 6 additions & 0 deletions dist/LoopbackModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ var LoopbackModel = function () {
var url = this.baseUrl + '/' + this.model + '/replaceOrCreate';
return this.post(url, data);
}
}, {
key: 'remote',
value: function remote(name, data) {
var url = this.baseUrl + '/' + this.model + '/' + name;
return this.post(url, data);
}
}]);

return LoopbackModel;
Expand Down
11 changes: 9 additions & 2 deletions src/LoopbackModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,16 @@ class LoopbackModel {
return this.post(url,data);
}

remote(name,data) {
remote(name,query,data) {

if(query && !data)
{
data = query
query = null
}

const url = `${this.baseUrl}/${this.model}/${name}`;
return this.post(url,data);
return this.post(url,data,query);
}
}

Expand Down

0 comments on commit 610bf9a

Please sign in to comment.