2.0.3 • Published 12 months ago

url-query-formatter v2.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

url-query-formatter

A simple utility function to append a query string to a URL.

Installation

You can install the package using npm:

npm install url-query-formatter

Usage

CommonJS

const { formatter } = require("url-query-formatter");

const url = "https://example.com";
const params = { key1: "value1", key2: "value2" };

const fullUrl = formatter(url, params);
console.log(fullUrl); // Output: https://example.com?key1=value1&key2=value2

ES Modules

import formatter from "url-query-formatter";

const url = "https://example.com";
const params = { key1: "value1", key2: "value2" };

const fullUrl = formatter(url, params);
console.log(fullUrl); // Output: https://example.com?key1=value1&key2=value2

Parameters

formatter(url, params)

  • url (string): The base URL to which the query string will be appended. It should be a valid URL format.
  • params (Object): An object containing key-value pairs that will be converted into query string parameters. Each key in the object represents a query parameter, and the associated value represents the parameter's value.

Author

2.0.3

12 months ago

2.0.2

12 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.0.0

1 year ago