question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to get user session for get request

See original GitHub issue

Hello Guys,

I am unable to get user session when user is logged in. For example if i want to get topics for specific user. so i need value of req.user.id on topic request. But is undefined. It looks like Bug in the code.

actions/topic.js

export function fetchTopics() { return { type: types.GET_TOPICS, promise: makeTopicRequest(‘get’) }; }

app/Containers/Votes.jsx

class Vote extends Component { … static need = [ fetchTopics ] … }

server/config/routes.js

app.get(‘/topic’, topicController.all);

server/controllers/topics.js

export function all(req, res) { console.log(req.user); // undefined Topic.find({}).exec((err, topics) => { if (err) { console.log(‘Error in first query’); return res.status(500).send(‘Something went wrong getting the data’); }

return res.json(topics);

}); }

Any Solution?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sidharthchughcommented, Aug 18, 2016

@jrodl3r you are right. Because currently i have to do hack fix to have GET while pushing to other route. We need to refactor this GET to have all the functions working properly as many people are posting in one or other thread.

@choonkending something is planned?

1reaction
jrodl3rcommented, Aug 18, 2016

don’t really understand #225 too well. However, certainly think the current GET solution is not sufficient. It feels so black-box, no handlers for Success/Failure (like POST has)… would be really nice to use fetch() onEnter/onLeave for routes, but the promise fires the db-controller twice… No idea why, but having access to GET on route-handlers would be nice. Also, would be able to decrypt fetched-response if there was a Success action/callback…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to get servlet request object and session
1 Answer 1 ... session = request.getSession( true );. if there is no current session and create is true, returns a new session....
Read more >
Advanced Usage — Requests 2.28.1 documentation
Advanced Usage¶. This document covers some of Requests more advanced features. Session Objects¶. The Session object allows you to persist certain parameters ...
Read more >
Not able to get session id using the /login api through nodejs ...
The login api is working absolutely fine with postman but when i try to implement the same in nodeJS I am getting the...
Read more >
Error 'Failed to send request' or unable to login with Data Loader
Users who attempt to connect to Salesforce via Data Loader login may receive an error: Failed to send request. This may be resolved...
Read more >
500 Internal Server Error | Apigee Edge
Diagnostic Steps for All Users · In the Trace tool, select the API request that has failed with 500 Internal Server Error. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found