Skip to content

Commit

Permalink
fix(rest-client): Allow to customize getting the query (#1594)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaddyWarbucks authored and daffl committed Nov 21, 2019
1 parent 3951626 commit 5f21272
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/rest-client/lib/base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const query = require('qs');
const qs = require('qs');
const { Unavailable } = require('@feathersjs/errors');
const { _ } = require('@feathersjs/commons');
const { stripSlashes } = require('@feathersjs/commons');
Expand All @@ -20,21 +20,25 @@ class Base {
this.base = `${settings.base}/${this.name}`;
}

makeUrl (params, id) {
params = params || {};
makeUrl (query, id) {
query = query || {};
let url = this.base;

if (typeof id !== 'undefined' && id !== null) {
url += `/${encodeURIComponent(id)}`;
}

if (Object.keys(params).length !== 0) {
const queryString = query.stringify(params);
return url + this.getQuery(query);
}

getQuery (query) {
if (Object.keys(query).length !== 0) {
const queryString = qs.stringify(query);

url += `?${queryString}`;
return `?${queryString}`;
}

return url;
return '';
}

find (params = {}) {
Expand Down

0 comments on commit 5f21272

Please sign in to comment.