Skip to content
New issue

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

how to access POST data? #55

Closed
julian-rare opened this issue Oct 10, 2016 · 1 comment · May be fixed by #86
Closed

how to access POST data? #55

julian-rare opened this issue Oct 10, 2016 · 1 comment · May be fixed by #86

Comments

@julian-rare
Copy link

an example would be great

@koistya
Copy link
Member

koistya commented Oct 10, 2016

@julian-rare this router is not designed to be used with POST requests. Here is an example how to handle POST request with Express.js:

import express from 'express';
import Router from 'universal-router';

const app = express();

// Authentication
app.post('/token', async (req, res, next) => {        // <---
  try {
    // TODO: Validate the request and issue an OAuth token
  } catch (err) { next(err); }
});

// Server-side rendering
app.get('*', async (req, res, next) => {
  try {
    const result = await Router.resolve(routes, { path: req.path });
    // TODO: Return HTML response
  } catch (err) { next(err); }
});

app.listen(process.env.PORT || 3000);

@koistya koistya closed this as completed Oct 10, 2016
@frenzzy frenzzy mentioned this issue Mar 29, 2017
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants