Created
April 22, 2023 02:26
-
-
Save olabamipetaiwo/e9133b62fc853800708ae39b3fe0d160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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