Here is my button
<a href='https://www.example.com/' ><img src='https://example.com/button.jpg' title='' /></a>
Here's my script:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("Authorization","Bearer:tokengoeshere");
var urlencoded = new URLSearchParams();
urlencoded.append("email", "bob@example.com");
urlencoded.append("identifier", "C00067891");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://importanturl/login/customer", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The button doesn't take me to the results but takes me to the url in the href. (as it should)
When I open the console it builds that URL for me because of the second to last line in the script, right... like so:
https://importanturl/login/customer/KpSZJ5OG4W08ET9DgNCXmSbgXkSUYlVCoyBe03LfLebYJmAuJC3Mv7XP8b58KOXkYf_YKVAzyonWHh1JlW6AkqsZu2LP4jnbvgT776_jWVKbUYBCjvmt6gllRD7ENPuNTH13Ab0AXpgu_oK1I5pQd7zZXzXO5ixKnKBjvfc6VjezRfgI6xONQ0fXorz4sHr0hIXVA6hFvaP4aaGeL879PgVJw-h2Oay7faMOdBR1QiCRB4AZhzuz81gulOilTZta8PIVeno7OC2xmdNX5n5yhsJi9z7o8y8dFn-FuxUF0HKdYFM8ivgocWj0LnVDRNscM_Douwgwxql-kz4Zk2ozfp-DK6DMGq4cq7jv9xuiQ1s=
What do i have to put in the button href so when they click the button it takes them to the above URL ^.. the one that populates in the console?
I tried something like this:
<a id="thisuniqueid" href='#' ><img src='https://example.com/button.jpg' title='' /></a>
and then this at the very last line of the script:
$("#thisuniqueid").attr("href", result);
I feel i'm on the right track but just need a little help to get this finished. Please any help would be greatly appreciated. Thank you.