diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index ae4a352f3..e0527320d 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -10,20 +10,17 @@ class APIRequest { this.rest = rest; this.client = rest.client; this.method = method; - this.path = path.toString(); this.route = options.route; this.options = options; + + const queryString = (querystring.stringify(options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); + this.path = `${path}${queryString ? `?${queryString}` : ''}`; } gen() { const API = this.options.versioned === false ? this.client.options.http.api : `${this.client.options.http.api}/v${this.client.options.http.version}`; - if (this.options.query) { - const queryString = (querystring.stringify(this.options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); - this.path += `?${queryString}`; - } - const request = snekfetch[this.method](`${API}${this.path}`, { agent }); if (this.options.auth !== false) request.set('Authorization', this.rest.getAuth());