Trying Chapter 2: User-Facing Backend Ticket: User Preferences

Able to fix the test “user-preferences”
But it actually cannot save the preference in Mongo DB via localhost webpage
with error on request.js:37

Any experts can help? as I am a newbie in nodejs but I really want to learn it, thanks in advance

Hi @Mitsui, welcome to the community.
Can you please share your code for save-user-preferences function that is handling this API?
Don’t forget to wrap the code with [spoiler]<--Your Code-->[/spoiler] tags.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

feel free to tell me if you require any further information, thanks for your help.

This is not

This is the code that calls your code. You are supposed to do all modification in the …DAO fields. In this case your code is the function UsersDAO.updatePreferences().

1 Like

I think it is already included in chapter 2 of M220JS course, there is router
router.save-> users.controller save function → then call usersDAO.updatePreferences

so I don’t really understand why it is not successfully save the preference, see if @steevej & @SourabhBagrecha have any idea?

Hi @Mitsui,
Your code looks good to me, can you please share the error that is getting logged in your terminal while saving preferences?

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

@SourabhBagrecha returned 500, don’t know why?