Backend/Microservices/PaymentService/server/src/Helpers/networkHelper.js
/**
    * Method to generate the query string params for a URL.
    * @param url: The base url.
    * @param params: The array containing the parameters to be added as key and value.
    * @returns {}: Returns the string URL with the params appended, else null.
    */
Method to generate the query string params for a URL.
@param url: The base url.
@param params: The array containing the parameters to be added as key and value.
@returns {}: Returns the string URL with the params appended, else null.
Method to generate the query string params for a URL . @param url : The base url . @param params : The array containing the parameters to be added as key and value . @returns {} : Returns the string URL with the params appended else null .
_generateQueryURL(url, params) {
      try {
         url = url.replace("?", "");
         if (params.length > 0) {
            const queryParams = new URLSearchParams();
            params.forEach(oneParam => {
               const key = Object.keys(oneParam)[0];
               const value = oneParam[key];
               queryParams.append(key, value);
            });
            let stringUrl = url;
            stringUrl = stringUrl.concat("?");
            let urlParams = queryParams.toString();
            return stringUrl + urlParams;
         } else
            return url;
      } catch (e) {
         return url;
      }
   }
_generateQueryURL ( url , params ) { try { url = url . replace ( "?" , "" ) ; if ( params . length > 0 ) { const queryParams = new URLSearchParams ( ) ; params . forEach ( oneParam => { const key = Object . keys ( oneParam ) [ 0 ] ; const value = oneParam [ key ] ; queryParams . append ( key , value ) ; } ) ; let stringUrl = url ; stringUrl = stringUrl . concat ( "?" ) ; let urlParams = queryParams . toString ( ) ; return stringUrl + urlParams ; } else return url ; } catch ( e ) { return url ; } }
Method to generate the query string params for a URL.
Method to generate the query string params for a URL .