We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Refrenced to #85
My API provides aliases for id. /users/me/ === /users/5, if current user's ID is 5. So, I've tried such approach:
users.read.fetch.before(function(req, res, context) { var userId = req.params.user_id if (userId === "me") { context.criteria.id = req.user.id } return context.continue; })
Not working. Any ideas?
this should work, can you please open a new issue so we can discuss this if there is an actual problem here.
var milestones = { users: require('./users.js') } var users = epilogue.resource({ model: db.User, associations: true }); users.use(milestones.users)
// ./users.js module.exports = { read: { start: function(req, res, context) { console.log(context); return context.continue; }, auth: function(req, res, context) { console.log(context); return context.continue; }, fetch: { before: function(req, res, context) { console.log(context); return context.continue; } } } }
GET /api/v0/users/me
{ instance: undefined, criteria: {}, attributes: {}, skip: [Function], stop: [Function], continue: [Function], error: [Function] } { instance: undefined, criteria: {}, attributes: {}, skip: [Function], stop: [Function], continue: [Function], error: [Function] } { instance: undefined, criteria: {}, attributes: {}, skip: [Function], stop: [Function], continue: [Function], error: [Function] }
criteria: { "id": "me" }
UPD: Also tried to access to req object directly:
auth: authMiddleware.E.ensureAuthenticated, fetch: { before: function(req, res, context) { console.log(context); // :me if (req.params.id === 'me') { context.criteria.id = req.user.id; } console.log(context); return context.continue; } }
Response is:
{ "message": "\"me\" is not a valid integer", "errors": [] }
The request doen't respect criteria: {} object, does it?
criteria: {}
The text was updated successfully, but these errors were encountered:
this looks like its an actual bug here. The logic needs to be something like: if (attribute in req.params && !!criteria[attribute])
if (attribute in req.params && !!criteria[attribute])
Sorry, something went wrong.
fixed in 470abb2
No branches or pull requests
Refrenced to #85
My API provides aliases for id. /users/me/ === /users/5, if current user's ID is 5. So, I've tried such approach:
Not working. Any ideas?
Tesing
GET /api/v0/users/me
Output
Expected
UPD: Also tried to access to req object directly:
Response is:
The request doen't respect
criteria: {}
object, does it?The text was updated successfully, but these errors were encountered: