I am not able to see the output of the user when the userId is present.
Here is my db.js file:
import { loadData } from './storage.js';
export const getUser = (userId) => new Promise((resolve, reject) => {
//check userId and reject if it's missing
if (!userId) {
reject(new Error("userId is missing."));
} else {
setTimeout(() => {
//use loadData and resolve with the user object if the id is present
let users = loadData();
for (let i = 0; i < users.length; i++) {
if (users.id[i] === userId) {
resolve(users[i]);
}
}
return {};
}, 200);
}
});