Create URLSearchParams from a JavaScript object.
Include the script on your page via UNPKG.
<script src="https://unpkg.com/searchparamify"></script>
Download dist/searchparamify.js.
Include it on your page.
<script src="searchparamify.js"></script>
Install via npm.
> npm install searchparamify
Include it in your scripts.
import searchparamify from "searchparamify";
Create URLSearchParams from a JavaScript object.
const params = searchparamify({
name: "Jimmy",
favoriteAnimal: "cat"
});
The result of the code above is identical to...
const params = new URLSearchParams();
params.append("name", "Jimmy");
params.append("favoriteAnimal", "cat");
In both cases, params.toString()
would return
"name=Jimmy&favoriteAnimal=cat"