react-project icon indicating copy to clipboard operation
react-project copied to clipboard

Wrong args in blueprint's API handler

Open frankychung opened this issue 8 years ago • 3 comments

After https://github.com/ryanflorence/react-project/pull/31, the args for https://github.com/ryanflorence/react-project/blob/master/create-react-project/blueprint/modules/api/hello.js#L1 need to be updated

// now
export default function (req, res, { params, location, route }) {
  ...
}

// correct
export default function (req, res, lastRoute, { params, location, route }) {
  ...
}

(In the README as well https://github.com/ryanflorence/react-project/blob/master/README.md#serverroutehandlerreq-res--params-location-route-)

However, the lastRoute and route args there are the same. Would it make sense to use props.route instead of adding a separate arg here in handleServerRoute?: https://github.com/ryanflorence/react-project/blob/master/modules/PublicServerAPI.js#L143

// now
function handleServerRoute(req, res, route, props) {
  const handler = route[req.method.toLowerCase()]
  ...
}

// perhaps?
function handleServerRoute(req, res, props) {
  const handler = props.route[req.method.toLowerCase()]
  ...
}

(Will gladly open a small PR for either one!)

frankychung avatar Mar 09 '16 03:03 frankychung

I think it makes more sense to use the param.route in this case. Fixing the bug the way it was appeared to not hurt anything. Thanks for catching that!

rtorr avatar Mar 10 '16 05:03 rtorr

Sorry, testing out ryans-ghn.herokuapp.com gonna close and reopen this thing.

ryanflorence avatar Mar 12 '16 15:03 ryanflorence

and now reopen

ryanflorence avatar Mar 12 '16 15:03 ryanflorence