We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 85cc30f commit 3fcb13eCopy full SHA for 3fcb13e
7-bank-project/solution/app.js
@@ -72,7 +72,12 @@ async function getAccount(user) {
72
async function createAccount(accountJson) {
73
return new Promise(resolve => {
74
setTimeout(() => {
75
- const data = JSON.parse(accountJson);
+ let data;
76
+ try {
77
+ data = JSON.parse(accountJson);
78
+ } catch (e) {
79
+ return resolve({ error: 'Malformed account data' });
80
+ }
81
if (!data.user) return resolve({ error: 'Username required' });
82
if (findAccount(data.user)) return resolve({ error: 'User already exists' });
83
// Set up initial account structure
0 commit comments