Hello, FreeCodeCampers.
I am currently developing a MERN app based on MERN stack course by Brad Traversy. The original app is a social network for developers.
I modified it a bit to be a job portal for developers. I decided to make 2 type of accounts: company and developer/user. Currently I am facing an issue of log in. From designing the database to registering the user, I think I already have no issue, at least compared to original app logic.
The logic of logging in is:
- I have a login page for 2 type of accounts for developer and company.
- When user click one of the submit buttons, the server side check for any errors and doesn’t continue the logging in process.
- When all of the input requirements is met, the server continue the logging in process then redirect the page to dashboard.
When I test the login of user/developer, the app has no error. But when I test the login of company, the app produce errors and can’t redirect to dashboard, but the account is successfully logged in.
If I change the URL to other part of the app beside than the dashboard (currently only create-profile page) the app forgets the error but when I visit back the dashboard, one of the errors (the first error below) shows up again.
Here is the link of the latest code: https://github.com/mrfazry/dev-jobs
First error:
TypeError: Cannot read property 'companyProfile' of undefined at Dashboard.render (Dashboard.js:28)
What is weird is, correct me if I’m wrong, the companyProfile
is already defined in one of the reducers from initialState
object. When I watched the reducers part of the course, all of them have initialState, so they are all defined right? Of course the Dashboard.js has access to companyProfile from connect
thing of react-redux
.
Second error:
Uncaught (in promise) TypeError: Cannot read property 'data' of undefined at authActions.js:99
authActions.js
has functions that use axios (both register and login, both company and developer). What is weird is when login company function is called, the log in still success but catch is still triggered. The catch is if there are errors.
Sorry if my explanation is so bad but I really don’t have any clue of these two problems. I don’t know what part of code to post because they are really long, so I only provide the link.