-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cast Error in API call #3
Comments
Hi Dave, I believe your problem is going to be fixed around here: Try console logging payload on line 41. For some reason, I've had a few people who are finding their _id elsewhere on the payload object. You'll have to manually track down where the data is coming through on this payload object sand update your code that is currently on line 41 (User.findById(payload._id, function(err, user)) accordingly. Please let me know if this works for you. Thank you, Josh |
Hi Joshua: The payload looks OK (to me at least): componentWillMount() { |
Okay, so it seems your client-side is making a request with an undefined user id: /api/user/undefined Try console logging userId const right after you load the uid cookie and before you fetchUser. Is that coming up undefined? Interesting. |
Yep, the console is showing nothing. I don't think GET http://localhost:3000/api/user/undefined 400 (Bad Request) Cheers, |
Solved - In my Navigation component I did this by just grabbing the cookie contents: ...
Then I displayed what I needed in the render / return statements with: Note: I tried using
BTW: I've integrated the mern-starter with the Inspinia theme so I can start making some nice elements for rapid prototyping. I'll let you know when it's up - hopefully this week. I might give the social login thingy a shot as well. Cheers, |
Dave, That's great you were able to solve this. Sorry, I've been pretty busy so it's tough to be super responsive. I look forward to seeing your work in combining the mern-starter with Inspinia! Good luck with the social integration. I'd love if you submitted a PR with social integration if you get that working. Thanks, Josh |
Hi Joshua: No problem, I understand the busy thing all too well (I was once a CTO of a Cheers, On Tue, Nov 1, 2016 at 12:56 PM, Joshua Anderson Slate <
|
Hi: Just an fyi, I put up what I have so far: Cheers, On Tue, Nov 1, 2016 at 6:51 PM, Dave Cook [email protected] wrote:
|
Hi, Awesome! I gave it a star and will watch it. I'm excited to see what you do :) Good luck, Josh |
Hi Joshua:
When I execute the api call to: http://localhost:8080/dashboard/profile I get the following error from the server: CastError: Cast to ObjectId failed for value "undefined" at path "_id".
I'm running the latest versions of everything in both client and server packages. It doesn't seem to be obtaining the _id from MongoDB. Have you seen this before?
BTW: Posting to the DB and registering etc. works fine.
Cheers,
Dave
The text was updated successfully, but these errors were encountered: