Skip to content

Commit

Permalink
Merge pull request #1741 from yuvipanda/binderhub-client-urlparams
Browse files Browse the repository at this point in the history
Use URLSearchParams() to construct query strings
  • Loading branch information
GeorgianaElena authored Sep 21, 2023
2 parents 05f0755 + d220cba commit 1d57da1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/packages/binderhub-client/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ export class BinderRepository {
* Call the BinderHub API
*/
fetch() {
let apiUrl = this.baseUrl + "build/" + this.providerSpec;
let apiUrl = new URL(this.baseUrl + "build/" + this.providerSpec);
let params = new URLSearchParams();
if (this.buildToken) {
apiUrl = apiUrl + `?build_token=${this.buildToken}`;
params.append('build_token', this.buildToken);
}

apiUrl.search = params.toString();

this.eventSource = new EventSource(apiUrl);
this.eventSource.onerror = (err) => {
console.error("Failed to construct event stream", err);
Expand Down

0 comments on commit 1d57da1

Please sign in to comment.