如何用 URLSearchParams 替换 querystring.stringify?
How to replace querystring.stringify with URLSearchParams?
querystring.stringify({
error: 'error_status'
})
'querystring' 已弃用,我将如何在此处将其替换为本机 URLSearchParams?
const params = new URLSearchParams({
error: 'error_status'
});
console.log(params.toString());
// error=error_status
console.log(`?${params.toString()}`);
// ?error=error_status
更多信息请访问 https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
querystring.stringify({
error: 'error_status'
})
'querystring' 已弃用,我将如何在此处将其替换为本机 URLSearchParams?
const params = new URLSearchParams({
error: 'error_status'
});
console.log(params.toString());
// error=error_status
console.log(`?${params.toString()}`);
// ?error=error_status
更多信息请访问 https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams