You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ISSUE:
In the POST route while registering the user, it is not specified that the user should have a third property as purchased of type array. As the user purchases the course, it should have a purchased property set while signing up where all the purchases would be saved.
ISSUE:
In the POST route while registering the user, it is not specified that the user should have a third property as purchased of type array. As the user purchases the course, it should have a purchased property set while signing up where all the purchases would be saved.
User Routes
GET: /users/purchasedCourses
Description: Lists all the courses purchased by the user. Input: Headers: { 'username': 'username', 'password': 'password' } Output: { purchasedCourses: [ { id: 1, title: 'course title', description: 'course description', price: 100, imageLink: 'https://linktoimage.com/', published: true }, ... ] }
POST: /users/signup
Description: Creates a new user account. Input: { username: 'user', password: 'pass' } Output: { message: 'User created successfully' }
SOLUTION:
USER SCHEMA should be:
const UserSchema = new mongoose.Schema({
// Schema definition here
username: String,
password: String,
purchased: Array,
});
&&
POST: /users/signup
Description: Creates a new user account. Input: { username: 'user', password: 'pass' }
newUser = {
username: req.headers.username,
password: req.headers.password,
purchased: [],
}
Output: { message: 'User created successfully' }
The text was updated successfully, but these errors were encountered: