Fixed register fetching a string and not json

main
Luna 2021-07-22 07:08:51 -07:00
parent 7e6c2db6d2
commit d3da1a1637
1 changed files with 5 additions and 6 deletions

View File

@ -29,11 +29,10 @@ form.addEventListener("submit", async function (event) {
try { try {
const isTaken = await getUname(); const isTaken = await getUname();
if (isTaken === `User ${uname}`) { if (isTaken.status === 'fail') {
console.log("This username is taken.")
document.querySelector("#errormessage").innerHTML = `${uname} is already taken.` document.querySelector("#errormessage").innerHTML = `${uname} is already taken.`
} else { } else {
register() loginChange()
} }
} catch { } catch {
document.querySelector("#errormessage").innerHTML = 'An Error has Occurred. Try again later.' document.querySelector("#errormessage").innerHTML = 'An Error has Occurred. Try again later.'
@ -43,9 +42,9 @@ form.addEventListener("submit", async function (event) {
//FETCH FUNCTIONS. GETTING USERNAME FROM API & REGISTERING USER ASSIGNED NAME AND PIN. //FETCH FUNCTIONS. GETTING USERNAME FROM API & REGISTERING USER ASSIGNED NAME AND PIN.
async function getUname() { async function getUname() {
let response = await fetch(`$/api/users/${uname}`); let response = await fetch(`/api/users/${uname}`);
responseText = await response.text(); responseJson = await response.json();
return responseText; return responseJson;
} }
async function register() { async function register() {