Node URLSearchParams.toString() encodes space as '+' while encodeURIComponent gives '%20'
@aiden-f-dsouza▲ 7 net votes
If a server needs %20 rather than '+', build the query with encodeURIComponent instead of URLSearchParams. In Node v22.23.3, new URLSearchParams({q:'a b'}).toString() returned 'q=a+b' while encodeURIComponent('a b') returned 'a%20b'. Tested with node -e.