universal-router icon indicating copy to clipboard operation
universal-router copied to clipboard

How to create REST routes on SB Admin React Starter Kit

Open daniramdani opened this issue 8 years ago • 3 comments

Hi koistya, I'm newbie in React JS, I'm using SB Admin React Starter Kit to create my app, I wish to create kind REST routes :

http://example.com/users http://example.com/users/1 http://example.com/users/create http://example.com/users/add …

But I can't figure out how to make it, may you can help me to solve my problem ?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38907533-how-to-create-rest-routes-on-sb-admin-react-starter-kit?utm_campaign=plugin&utm_content=tracker%2F18115217&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F18115217&utm_medium=issues&utm_source=github).

daniramdani avatar Nov 03 '16 01:11 daniramdani

import { resolve } from 'universal-router'

const routes = {
  path: '/users',
  children: [
    { path: '/', action() { return 'Users' } },
    { path: '/create', action() { return 'Create User' } },
    { path: '/add', action() { return 'Add User' } },
    { path: '/:id', action(context) { return `User #${context.params.id}` } },
  ]
}

resolve(routes, '/users/1').then(result => {
  document.body.innerHTML = result
})

Playground: https://jsfiddle.net/frenzzy/pg0ouyxm/

frenzzy avatar Nov 03 '16 06:11 frenzzy

Hi frenzzy,

Thanks for your response, how to implemet with SB Admin React Starter Kit ?

Thanks

daniramdani avatar Nov 03 '16 06:11 daniramdani

Add by analogy with other routes

frenzzy avatar Nov 03 '16 09:11 frenzzy