Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. export const queryBuilder = function(objParams){
  2.  
  3. if("[object Object]" === Object.prototype.toString.call(objParams)){
  4.  
  5. const arrKeys = Object.keys(objParams)
  6.  
  7. if(arrKeys.length>0){
  8.  
  9. return arrKeys.map(function(key) {
  10.  
  11. let value = objParams[key];
  12.  
  13. if(null != value && "undefined" !== typeof value){
  14. return key + '=' + objParams[key]
  15. }
  16.  
  17. }).join('&')
  18. }
  19.  
  20. }
  21.  
  22. return ""
  23.  
  24. }
  25.  
  26. export const urlBuilder = function(url,objParams){
  27.  
  28. return url + "?" + queryBuilder(objParams);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement