[Poly > Request] Replace deprecated querystring with URLSearchParams

This commit is contained in:
Ducko 2022-02-16 15:18:17 +00:00
parent a0569aeeb0
commit 6fa918c6c7

View file

@ -1,9 +1,8 @@
const https = require('https'); const https = require('https');
const querystring = require("querystring");
// Generic polyfill for "request" npm package, wrapper for https // Generic polyfill for "request" npm package, wrapper for https
const nodeReq = ({ method, url, headers, qs, timeout, body, stream }) => new Promise((resolve) => { const nodeReq = ({ method, url, headers, qs, timeout, body, stream }) => new Promise((resolve) => {
const fullUrl = `${url}${qs != null ? `?${querystring.stringify(qs)}` : ''}`; // With query string const fullUrl = `${url}${qs != null ? `?${(new URLSearchParams(qs)).toString()}` : ''}`; // With query string
let req; let req;
try { try {