@zubeir68 wrote:
Hi, i am struggling with getting the currentUser in a session when authenticated. I am trying to get current User with dedicated endpoint
/users/me
but I don’t receive any query parameters so that I can get fetch it by username. I am using Express.js backendHere is my current-user service:
import Service from '@ember/service'; import { inject as service } from '@ember/service'; import RSVP from 'rsvp'; export default Service.extend({ session: service(), store: service(), load() { console.log(this.get('session.isAuthenticated')); if (this.get('session.isAuthenticated')) { return this.get('store').queryRecord('user', { me: true }).then((user) => { console.log('user: ', user ); this.set('user', user); }); } else { return RSVP.resolve(); } } });
Here is the user.js adapter which I got from the ESA guide:
import ApplicationAdapter from './application'; export default ApplicationAdapter.extend({ urlForQueryRecord(query) { if (query.me) { delete query.me; return `${this._super(...arguments)}/me`; } return this._super(...arguments); } });
This is the /users/me endpoint:
router.get('/users/me', asyncHandler(async (req, res, next) => { console.log(req.query); console.log(req.body); }));
I think I missunderstood something. Thank you for any help
Posts: 1
Participants: 1