Missing Params?

18 views
Skip to first unread message

Paul Tiseo

unread,
Mar 3, 2015, 1:19:08 PM3/3/15
to action...@googlegroups.com
My routes:

all: [
 
{ path: '/auth/:provider', action: 'auth'},
 
{ path: '/auth/:provider/:state', action: 'auth'}
]

My action:

exports
.action = {
  name
:                   'auth',
  description
:            'Authenticates a connection based on provider and the state of the process',
  blockedConnectionTypes
: [],
  outputExample
:          {},
  matchExtensionMimeType
: false,
  version
:                1.0,
  toDocument
:             true,

  inputs
: {
   
'required': ['provider'],
   
'optional': ['state']
 
},

  run
: function(api, connection, next) {
    console
.log('entering action.auth.run');
    console
.log(connection.params);
   
// your logic here
   
next(connection, true);
 
}
};


My output for http://localhost:8080/api/auth/local/:
entering action.auth.run
{ action: 'auth', apiVersion: 1 }

This is on a pretty virginalWhy would the route params not be in connection.params?

Michael Jensen

unread,
Mar 3, 2015, 1:37:04 PM3/3/15
to Paul Tiseo, action...@googlegroups.com
Hi Paul,

If you're running Actionhero v10, the format for parameter declaration has changed! Check out http://www.actionherojs.com/docs/core/actions.html#inputs for all the details. In your case, it looks like you need to change inputs to look like this:

inputs: {
  provider: {
    required: true
  },
  state: {
    required: false
  }
}

Actionhero will filter out params that are not properly defined like this. Hope that helps!


--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Tiseo

unread,
Mar 3, 2015, 2:23:37 PM3/3/15
to action...@googlegroups.com, paulx...@gmail.com
Ok, yes, that was it. Sorry. Just put on my dunce cap. :)

(In my defense, I used ActionHero a while back, before that change, and just went with what I knew...)
Reply all
Reply to author
Forward
0 new messages