const quParams = {sample1: 'one', sample2: 'one+one/two', sample3: 'testing'}
if (Object.keys(quParams).length) {
const api_params = `&${Object.keys(quParams).map(x => `${x}=${quParams[x]}`).join("&")}`
console.log('api_params>>>>>>>>>>', api_params)
}
`
const quParam = {sample1 : 'one', sample2: 'one%2Bone%2Ftwo'}
let objKeys = Object.keys(quParam);
let quParamValue = ''
for (item of objKeys) {
quParam[item];
if (item === 'sample2') {
quParamValue = quParam[item].replaceAll('%2F', '/').replaceAll('%2B','+')
console.log('quParamValue>>>>>>', quParamValue)
}
}
`one of the query params of client side url has Special Character in the param(sample2)
https://example.com/endpointService?sample1=one&sample2=one+one/two
When passing this url from client side to server side it is encoded as
https://testing.com/endpointService?sample1=one&sample2=one%2Bone%2Ftwo
When passing this encodedURL to RESTFUL api service, is not giving good response.
How to handle this scenario..
Where and how we have to encode & decode the query value using JS
Client (React JS) >>> Server (Express JS) >>> Restful Service
How to do it without replacing on node js