Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Migrate from legacy querystring to URLSearchParams #116

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
request as httpRequest
} from "http";
import { request as httpsRequest, RequestOptions } from "https";
import * as querystring from "querystring";
import * as zlib from "zlib";
import { ServiceClientError } from "./client";
import { Socket } from "net";
import { Readable } from "stream";
import { URLSearchParams } from "url";

const DEFAULT_READ_TIMEOUT = 2000;
const DEFAULT_CONNECTION_TIMEOUT = 1000;
Expand Down Expand Up @@ -53,7 +53,7 @@ interface Span {

export interface ServiceClientRequestOptions extends RequestOptions {
pathname: string;
query?: object;
query?: { [key: string]: string | string[] | undefined };
timing?: boolean;
autoDecodeUtf8?: boolean;
dropRequestAfter?: number;
Expand Down Expand Up @@ -200,7 +200,7 @@ export const request = (

if ("pathname" in options && !("path" in options)) {
if ("query" in options) {
let query = querystring.stringify(options.query);
let query = new URLSearchParams(options.query).toString();
if (query) {
query = "?" + query;
}
Expand Down