I'm troubleshooting why my post request isn't generating a new JSON file. I've implemented a JS POST fetch request in the code snippet below.
//All variables are assumed to be defined
fetch(lowercaseUsernameStr+'_profile_data.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: {
"publicData": {
"username": usernameStr,
"userDescription": userDescription,
"favoriteGameData": {
"favoriteGameCategory": favoriteGameCategoryStr,
"favoriteGameNum": favoriteGameNum
},
"stats": {
"level": 1,
"levelXP": 0,
"maxLevelXP": 100,
"XPUntilNextLevel": 100,
"totalXP": 0,
"trophies": 0
}
},
"privateData": {
"password": passwordStr,
"email": email,
"telNum": telNum,
"userProfilePageVisibilityYesOrNo":
optionsSelectedOptionStr,
"userProfilePictureSrc": userProfilePictureSrc
}
}
})
.catch((error)=>{
alert("Sorry! We could not create your account! Please report the problem and wait until it's fixed! Here is the error: " + error);
//Assume the local url exists
document.location = 'contact_and_email_will.html';
});