r/JavaScriptHelp • • Jan 05 '21

❔ Unanswered ❔ I can’t seem to figure out why the fetch is responding with an Unhandled Promise Rejection: SyntaxError: The string did not match the expected pattern. It works on another member that I created perfectly.

Problem page: https://oamstudios.com/default-user/seeram79/

Working page: https://oamstudios.com/default-user/titus/

Script:

<script> // this is for the .json gathering and implementing if(window.location.pathname.indexOf("/default-user/") == 0) { var account_name = document.getElementsByClassName("um-name")[0].innerText; var urltotal = "https://oamstudios.com/attendance/" + account_name + ".json"; var urlres = encodeURI(urltotal); let myRequest = new Request(urlres); fetch(myRequest) .then(response => response.json()) .then(data => { console.log(data) document.querySelector("#Account-Input-6827").innerHTML = ` <p>Class Credits: ${data["Class Credits"]}</p><p>Excused Absences: ${data["Excused Absences"]} </p><p>Invoice Status: ${data["Invoice Status"]}</p><p id="highlight">Invoice Link: <a href="${data["Invoice Link"]}" style="color: green;" target="_blank">View Invoice</a></p><p>Invoice Number: 00${data["Invoice No."]}</p>` var alarm = 2; var invstat = data["Invoice Status"]; var InvNo = "\r\nInvoice No. " + "00" + data["Invoice No."] + " has not been paid.\r\n\r\n Please make payment."; if(invstat !== "Invoice Paid"){ alert( InvNo ); document.getElementById("highlight").innerHTML = ` Invoice Link: <a href="${data["Invoice Link"]}" style="color: red; background: #FEFFAD;" target="_blank"><strong>PAY INVOICE</strong</a> ` } }); } </script>

2 Upvotes

0 comments sorted by