How to get the headers parameters in the url forwarded through the background?

for example, after a business is processed in the background, the backend forwards a url to the front-end route, and puts a parameter in the response headers in this url. So, how do you get this parameter? Does js have an idea? Thank you.

Mar.02,2021

  1. if there are not many parameters, you can put it directly in url.
  2. use document.location.href to get the returned url,
  3. define a parsed url function:
function urlParse(urlString){
  // let url = decodeURIComponent(urlString);
  let url = urlString;
  let obj = {};
  let reg = /[?&][^?&]+=[^?&]+/g;
  let arr = url.match(reg);
  if(arr){
      arr.forEach((item)=>{
          let  tempArr =  item.substring(1).split('=');
          let key = decodeURIComponent(tempArr[0]);
          let value = decodeURIComponent(tempArr[1]);
          obj[key] = value;
      })
  }
  return obj;
}

the above function returns a json object;

4. Then print that object, and you can start playing

.
Menu