0

I need to access the parameters of an outside website's url, here's what I've tried so far:

fetch('https://someotherwebsite.com?code=aLongString');
    .then(getParams => {
        const params = new URLSearchParams(window.location.search);
        const code = params.get('code')
        console.log(code)
    }
)

But it isn't working. Can anyone please help?

Edit: I failed to mention that the url I am trying to fetch includes a redirect_uri parameter. Which means when I actually hit that url I get taken to a different page with a different url, and it is the second url I am trying to access.

Url I want to fetch:

`https://someotherwebsite.com?redirect_uri=https://differentwebsite.com`

Returns Url I want to access:

`https://differentwebsite.com?code=aLongString`

Currently my code variable is just returning undefined

sgt_pepper85
  • 421
  • 4
  • 14

0 Answers0