dvajs / dva-example-user-dashboard

๐Ÿ‘ฒ ๐Ÿ‘ฌ ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ง ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ
446 stars 205 forks source link

I just wanna to know where are you get the mock/fake data ??? #28

Closed xyzdata closed 7 years ago

xyzdata commented 7 years ago
import request from '../utils/request';
// request(url, options)
import { PAGE_SIZE } from '../constants';
// ๅˆ†้กต size 3

// http://localhost:8000/sockjs-node/info?t=1499839053437
// GET
// ??? where  are you get the mock/fake datas ??? 

export function fetch({ page }) {
    // http://localhost:8000/users?page=2
    // http://localhost:8000/api/users?_page=2&_limit=3
    // GET
    return request(`/api/users?_page=${page}&_limit=${PAGE_SIZE}`);
}

// http://localhost:8000/api/users/4
// DELETE
export function remove(id) {
    return request(`/api/users/${id}`, {
        method: 'DELETE'
    });
}

// http://localhost:8000/api/users/4
// PATCH
export function patch(id, values) {
    return request(`/api/users/${id}`, {
        method: 'PATCH',
        body: JSON.stringify(values)
    });
}

// http://localhost:8000/api/users/4
// POST
export function create(values) {
    return request('/api/users', {
        method: 'POST',
        body: JSON.stringify(values)
    });
}
xyzdata commented 7 years ago

smg

http://jsonplaceholder.typicode.com/

{
    "entry": "src/index.js",
    "disableCSSModules": false,
    "publicPath": "/",
    "theme": {
        "@primary-color": "#1DA57A",
        "@link-color": "#1DA57A",
        "@border-radius-base": "2px",
        "@font-size-base": "16px",
        "@line-height-base": "1.2"
    },
    "autoprefixer": null,
    "proxy": {
        "/api": {
            "target": "http://jsonplaceholder.typicode.com/",
            "changeOrigin": true,
            "pathRewrite": { "^/api": "" }
        }
    },
    "extraBabelPlugins": [
        "transform-runtime", ["import", { "libraryName": "antd", "style": true }]
    ],
    "env": {
        "development": {
            "extraBabelPlugins": [
                "dva-hmr"
            ]
        }
    },
    "dllPlugin": {
        "exclude": [
            "babel-runtime"
        ],
        "include": [
            "dva/router",
            "dva/saga",
            "dva/fetch"
        ]
    }
}

    "private": true,
    "scripts": {
        "start": "roadhog server",
        "build": "roadhog build",
        "build:dll": "roadhog buildDll",
        "test": "roadhog test",
        "lint": "eslint --ext .js src test",
        "precommit": "npm run lint",
        "prestart": "npm run build:dll"
    },
    "dependencies": {
        "antd": "^2.6.4",
        "babel-runtime": "^6.22.0",
        "dva": "^1.2.0",
        "dva-loading": "^0.2.0",
        "react": "^15.4.2",
        "react-dom": "^15.4.2"
    },
    "devDependencies": {
        "babel-eslint": "^7.1.1",
        "babel-plugin-dva-hmr": "^0.3.2",
        "babel-plugin-import": "^1.1.0",
        "babel-plugin-transform-runtime": "^6.22.0",
        "eslint": "^3.14.0",
        "eslint-config-airbnb": "^14.0.0",
        "eslint-plugin-import": "^2.2.0",
        "eslint-plugin-jsx-a11y": "^3.0.2",
        "eslint-plugin-react": "^6.9.0",
        "expect": "^1.20.2",
        "husky": "^0.13.0",
        "redbox-react": "^1.3.2",
        "roadhog": "^0.6.0"
    }
}

bug !

"prestart": "npm run build:dll"

xyzdata commented 7 years ago

react-fake-props

https://jsonplaceholder.typicode.com/

https://github.com/typicode/react-fake-props

import path from 'path'
import fakeProps from 'react-fake-props'

const componentPath = path.join(__dirname, './Component.jsx')
const props = fakeProps(componentPath)
nikogu commented 7 years ago

https://github.com/dvajs/dva-example-user-dashboard/blob/master/.roadhogrc#L13

xyzdata commented 7 years ago

.roadhogrc, it's really hard to read!