Skip to content

Wrong args in blueprint's API handler #36

@frankychung

Description

@frankychung

After #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!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions