0
onButtonClick= (authLink) => {

            if(authLink){
                window.open(authLink, '_blank');
            }
     };

response from this url is :-

{
"statusCode":"STATUS_OK",
"statusMessage":"The operation was successful.",
"statusUserMessage":"The operation was successful.",
"authToken":"AJFCNA",
"opaqueData":
    {"accessToken":"SJD.skb.zV-sdb-kajsb-dkjbc"},
     "authTokenValidity":21600,
    }
}

How to get this response in my code, I want to get the value for the key authToken. I have no idea. what can I do for this ?

Sudheesh Singanamalla
  • 2,283
  • 3
  • 19
  • 36

1 Answers1

0

I'm not sure what do you mean by "URL hit is not an ajax hit". You should be able to get the data using AJAX:

fetch(authLink)
  .then(response => response.json())
  .then(data => { console.log(data.authToken) })
  .catch(err => { console.error(err) })

If for some reason you can't / don't want to use AJAX, and really need to call window.open(), you can check some interesting answers here: How to get element and html from window.open js function with jquery

Miguel Calderón
  • 3,001
  • 1
  • 16
  • 18