From 610bf9a350fed5faf0bec773f534a39508840577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20GUILLY?= Date: Mon, 11 Jun 2018 18:07:32 +0200 Subject: [PATCH] add query to remote --- README.md | 2 ++ dist/LoopbackModel.js | 6 ++++++ src/LoopbackModel.js | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 81334be..b47dd05 100644 --- a/README.md +++ b/README.md @@ -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 + diff --git a/dist/LoopbackModel.js b/dist/LoopbackModel.js index 00b5989..3cbc09b 100644 --- a/dist/LoopbackModel.js +++ b/dist/LoopbackModel.js @@ -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; diff --git a/src/LoopbackModel.js b/src/LoopbackModel.js index 494b3e9..9a29005 100644 --- a/src/LoopbackModel.js +++ b/src/LoopbackModel.js @@ -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); } }