Skip to content

Instantly share code, notes, and snippets.

@olabamipetaiwo
Created April 22, 2023 02:26
Show Gist options
  • Save olabamipetaiwo/e9133b62fc853800708ae39b3fe0d160 to your computer and use it in GitHub Desktop.
Save olabamipetaiwo/e9133b62fc853800708ae39b3fe0d160 to your computer and use it in GitHub Desktop.
const generateURL = (params) => {
const BASE_URL = "http://testurl.bitfinx.com/";
const generatedURL = new URL(BASE_URL);
Object.keys(params).map((key) => {
params[key] &&
params[key].toString().length > 0 &&
generatedURL.searchParams.append(key, params[key]);
return true;
});
return generatedURL.href;
};
const _params = {
width: 300,
height: 360,
locale: "en",
toolbar_bg: "red",
interval: "3h",
pair: "BTC_USD",
};
const _URL = generateURL(_params);
console.log("URL is::", _URL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment