Vanilla JS equivalent of $.param()

The fetch API is missing the rather needed feature of being able to use an object to create a query string.
What is the simplest vanilla way of recreating the functionality of the jQuery function $.param() ?

Hi @0llieW, I think the internet is already full of solutions for you. Maybe this one has what you’re looking for:

Hope that helps…

I thought nowadays there might be a terser solution, possibly utilising url.searchParams

var url = //some url
var url = new URL(url)
url.searchParams.set(“foo”, “honeybooboo”);

Well if you’re using node and npm you’re surely in luck:
As for vanilla JavaScript, it never has had a huge inbuilt function library…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.